搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
HTML/CSS
CSS 参考手册
CSS 参考手册
源代码
清空
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Example of CSS top Property Animation- 基础教程(div.cn)</title> <style> .container{ position: relative; } .animated { width: 150px; padding: 40px 0; position: absolute; top: 0; font: bold 46px sans-serif; text-align: center; background: #9acd32; border: 1px solid #7da628; -webkit-animation: test 4s infinite; /* Chrome, Safari, Opera */ animation: test 4s infinite; } /* Chrome, Safari, Opera */ @-webkit-keyframes test { 50% {top: 300px;} } /* Standard syntax */ @keyframes test { 50% {top: 300px;} } </style> </head> <body> <p><strong>Warning:</strong> CSS Animations do not work in Internet Explorer 9 and earlier versions.</p> <p><strong>Note:</strong> The top position of the following DIV element is animating from its initial value "0" to "300px", and back to the initial value "0" again up to infinite times.<p> <div class="container"> <div class="animated">Box</div> </div> </body> </html>
运行结果