搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
HTML/CSS
CSS 参考手册
CSS 参考手册
源代码
清空
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CSS3 opacity 属性动画示例- 基础教程(div.cn)</title> <style> .container{ width: 300px; height: 200px; position: relative; background: #db75d6; border: 5px solid #a0299a; } .animated { opacity: 0; width: 200px; padding: 75px 0; margin: 50px; font: bold 46px sans-serif; background: #6f5ece; outline: 5px solid #4936b4; text-align: center; -webkit-animation: test 4s infinite; /* Chrome, Safari, Opera */ animation: test 4s infinite; } /* Chrome, Safari, Opera */ @-webkit-keyframes test { 50% {opacity: 1;} } /* Standard syntax */ @keyframes test { 50% {opacity: 1;} } </style> </head> <body> <p> <strong>警告:</strong>:CSS动画在Internet Explorer 9和更早版本中不起作用。</p> <p> <strong>注意:</strong>:蓝色DIV框的不透明度(即透明度)从其初始值“ 0”变为“ 1”,然后再次回到初始值“ 0”直至无限 次。</p> <div class="container"> <div class="animated">Box</div> </div> </body> </html>
运行结果