小白教程
所有教程
关于
Search
172.70.126.43
172.70.126.43
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Css3 pr animation direction”的源代码
本页内容
上一节:
Css3_pr_animation_iteration_count
下一节:
Css3_pr_animation_play_state
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:animation-direction}}[[Category:css reference|37]] = CSS3 animation-direction 属性 = [[css reference|CSS 参考手册]] 先执行一遍动画,然后再反向执行一遍动画: <sample title="" desc="" lang="html" hererun="1"> animation-direction:alternate; -webkit-animation-direction:alternate; /* Safari 和 Chrome */ </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> div { width:100px; height:100px; background:red; position:relative; animation:myfirst 5s infinite; animation-direction:alternate; /* Safari 和 Chrome */ -webkit-animation:myfirst 5s infinite; -webkit-animation-direction:alternate; } @keyframes myfirst { 0% {background:red; left:0px; top:0px;} 25% {background:yellow; left:200px; top:0px;} 50% {background:blue; left:200px; top:200px;} 75% {background:green; left:0px; top:200px;} 100% {background:red; left:0px; top:0px;} } @-webkit-keyframes myfirst /* Safari 和 Chrome */ { 0% {background:red; left:0px; top:0px;} 25% {background:yellow; left:200px; top:0px;} 50% {background:blue; left:200px; top:200px;} 75% {background:green; left:0px; top:200px;} 100% {background:red; left:0px; top:0px;} } </style> </head> <body> <p><strong>注意:</strong>Internet Explorer 9 及其之前的版本不支持 animation-direction 属性。</p> <div></div> </body> </html> </run> == 浏览器支持 == 表格中的数字表示支持该属性的第一个浏览器版本号。 紧跟在 -webkit-, -ms- 或 -moz- 前的数字为支持该前缀属性的第一个浏览器版本号。 {| class="table table-striped table-hover" ! 属性 ! Chrome ! Internet Explorer / Edge ! Firefox ! Safari ! Opera |- | animation-direction | 43.04.0 -webkit- | 10.0 | 16.05.0 -moz- | 9.04.0 -webkit- | 30.015.0 -webkit-12.0 -o- |} == 定义和用法 == animation-direction 属性定义是否循环交替反向播放动画。 '''注意:'''如果动画被设置为只播放一次,该属性将不起作用。 {| class="table table-striped table-hover" |width="50%"| 默认值: |width="50%"| normal |- | 继承: | 否 |- | 可动画化: | 否。请参阅 [[css animatable|可动画化(animatable)]]。 |- | 版本: | CSS3 |- | JavaScript 语法: | object.style.animationDirection="reverse" <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> div { width:100px; height:100px; background:red; position:relative; animation:mymove 5s infinite; /* Safari、Chrome 和 Opera */ -webkit-animation:mymove 5s infinite; } @keyframes mymove { from {left:0px;} to {left:200px;} } /* Safari、Chrome 和 Opera */ @-webkit-keyframes mymove { from {left:0px;} to {left:200px;} } </style> </head> <body> <p>点击“尝试一下”按钮,反转动画的方向。</p> <button onclick="myFunction()">尝试一下</button> <script> function myFunction() { document.getElementById("myDIV").style.animationDirection = "reverse"; // 针对 Chrome、Safari 和 Opera 的代码 document.getElementById("myDIV").style.WebkitAnimationDirection = "reverse"; } </script> <p><strong>注意:</strong>只有 Firefox 支持 animationDirection 属性。</p> <div id="myDIV"></div> </body> </html> </run> |} == CSS 语法 == <pre> animation-direction: normal|reverse|alternate|alternate-reverse|initial|inherit;</pre> == 属性值 == {| class="table table-striped table-hover" ! 值 ! 描述 ! 测试 |- | normal | 默认值。动画按正常播放。 | [[playit.php?f=playcss_animation direction&preval=normal|测试 »]] |- | reverse | 动画反向播放。 | [[playit.php?f=playcss_animation direction&preval=reverse|测试 »]] |- | alternate | 动画在奇数次(1、3、5...)正向播放,在偶数次(2、4、6...)反向播放。 | [[playit.php?f=playcss_animation direction&preval=alternate|测试 »]] |- | alternate-reverse | 动画在奇数次(1、3、5...)反向播放,在偶数次(2、4、6...)正向播放。 | [[playit.php?f=playcss_animation direction&preval=alternate reverse|测试 »]] |- | initial | 设置该属性为它的默认值。请参阅 [[css initial|initial]]。 | |- | inherit | 从父元素继承该属性。请参阅 [[css inherit|inherit]]。 | |} == 相关文章 == CSS3 教程:[[css3 animations|CSS3 动画(Animations)]] [[css reference|CSS 参考手册]]
返回至“
Css3 pr animation direction
”。
上一节:
Css3_pr_animation_iteration_count
下一节:
Css3_pr_animation_play_state