搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
HTML/CSS
CSS 参考手册
CSS 参考手册
源代码
清空
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CSS3 flex-shrink 属性动画示例- 基础教程(div.cn)</title> <style> .flex-container { width: 300px; height: 200px; font-size: 32px; border: 1px solid black; display: -webkit-flex; /* Safari */ display: flex; /* Standard syntax */ } .flex-container div { -webkit-flex: 1 1 200px; /* Safari 6.1+ */ -ms-flex: 1 1 200px; /* IE 10 */ flex: 1 1 200px; /* Standard syntax */ } .item1 { background: #e84d51; } .item2 { background: #7ed636; } .item3 { background: #2f97ff; } .animated { -webkit-animation: test 4s infinite; /* Chrome, Safari, Opera */ animation: test 4s infinite; } /* Chrome, Safari, Opera */ @-webkit-keyframes test { 50% {-webkit-flex-shrink: 2;} } /* Standard syntax */ @keyframes test { 50% {flex-shrink: 2;} } </style> </head> <body> <p> <strong>警告:</strong>:CSS动画在Internet Explorer 9和更早版本中不起作用。</p> <p> <strong>注意</strong>:flex item2的flex-shrink属性从其初始值“ 1”变为“ 2”,然后再次回到初始值“ 1”,直至无限次。 </p> <div class="flex-container"> <div class="item1">1</div> <div class="item2 animated">2</div> <div class="item3">3</div> </div> </body> </html>
运行结果