CSS3 旋转动画无法运行
尽管使用了最新稳定版本的 Chrome,但在使 CSS3 旋转动画运行时遇到问题。
根本原因:
要有效地利用 CSS3 动画,您还必须使用 @keyframes 规则定义动画关键帧。您尚未为“旋转”动画定义这些关键帧。
答案的 Markdown 语法:
<p>To use CSS3 Animation you must also define the actual animation keyframes (<em>which you named spin</em>)</p> <p>Read https://developer.mozilla.org/en-US/docs/CSS/Tutorials/Using_CSS_animations for more info</p> <blockquote> <p>Once you've configured the animation's timing, you need to define the appearance of the animation. This is done by establishing two or more keyframes using the @keyframes at-rule. Each keyframe describes how the animated element should render at a given time during the animation sequence.</p> </blockquote>
更新的 Fiddle 演示:
<div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-css lang-css prettyprint-override">div { margin: 20px; width: 100px; height: 100px; background: #f00; -webkit-animation-name: spin; -webkit-animation-duration: 4000ms; -webkit-animation-iteration-count: infinite; -webkit-animation-timing-function: linear; -moz-animation-name: spin; -moz-animation-duration: 4000ms; -moz-animation-iteration-count: infinite; -moz-animation-timing-function: linear; -ms-animation-name: spin; -ms-animation-duration: 4000ms; -ms-animation-iteration-count: infinite; -ms-animation-timing-function: linear; animation-name: spin; animation-duration: 4000ms; animation-iteration-count: infinite; animation-timing-function: linear; } @-ms-keyframes spin { from { -ms-transform: rotate(0deg); } to { -ms-transform: rotate(360deg); } } @-moz-keyframes spin { from { -moz-transform: rotate(0deg); } to { -moz-transform: rotate(360deg); } } @-webkit-keyframes spin { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(360deg); } } @keyframes spin { from { transform:rotate(0deg); } to { transform:rotate(360deg); } }
<div></div>
以上是为什么我的 CSS3 旋转动画在 Chrome 中不起作用?的详细内容。更多信息请关注PHP中文网其他相关文章!