搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
HTML/CSS
CSS 参考手册
CSS 参考手册
源代码
清空
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Example of CSS3 transform Property Animation- 基础教程(div.cn)</title> <style> .container{ margin: 25px; } .container img{ -webkit-animation: test 4s infinite; /* Chrome, Safari, Opera */ animation: test 4s infinite; /* Standard syntax */ } /* Chrome, Safari, Opera */ @-webkit-keyframes test { 50% {-webkit-transform: rotate(360deg);} } /* Standard syntax */ @keyframes test { 50% {transform: rotate(360deg);} } /* Example of 3D Transform */ .container-3d{ margin: 25px; width: 125px; height: 125px; perspective: 300px; border: 4px solid #a2b058; background: #f0f5d8; } .container-3d img{ /* Chrome, Safari, Opera */ -webkit-animation: test3d 4s infinite; -webkit-transform-origin: right center 0; /* Standard syntax */ animation: test3d 4s infinite; transform-origin: right center 0; } /* Chrome, Safari, Opera */ @-webkit-keyframes test3d { 50% { -webkit-transform: rotate3d(0, 1, 0, 180deg); /* Chrome, Safari, Opera */ } } /* Standard syntax */ @keyframes test3d { 50% { transform: rotate3d(0, 1, 0, 180deg); /* Standard syntax */ } } </style> </head> <body> <p> <strong>警告:</strong>:CSS动画在Internet Explorer 9和更早版本中不起作用。</p> <p> <strong>注意</strong>:“星鱼”图像从其原始位置沿顺时针方向旋转360度,然后又无限次地回到原始位置。</p> <div class="container"> <img src="/run/images/star-fish.png" alt="Star Fish"> </div> <hr> <p><strong>Note:</strong> “俱乐部卡片”图像在3D空间中沿Y轴(即,右边缘)旋转180度,并再次回到原始位置,直到无穷多次。<p> <div class="container-3d"> <img src="/run/images/club.jpg" alt="Club Card"> </div> </body> </html>
运行结果