codecamp

HTML DOM Style animation 属性

Style animation 属性

Style 对象参考手册 Style 对象

实例

使用速记属性改变 <div> 元素的动画:

document.getElementById("myDIV").style.animation="mymove 5s infinite";

尝试一下 »

定义和用法

animation 属性是六个动画属性的速记属性:

animationName
animationDuration
animationTimingFunction
animationDelay
animationIterationCount
animationDirection.

注意:总是规定 animationDuration 属性,否则持续时间为 0,将不播放动画。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10、Firefox 和 Opera 支持 animation 属性。

Safari 和 Chrome 支持另一个可替代该属性的属性,即 WebkitAnimation 属性。

注意:Internet Explorer 9 及其之前的版本不支持 animation 属性。


语法

返回 animation 属性:

object.style.animation

设置 animation 属性:

object.style.animation="name duration timingFunction delay iterationCount direction fillMode playState"

属性值

值 描述
animationName 指定要绑定到选择器的关键帧的名称。
animationDuration 规定动画完成需花费的秒数或毫秒数。
animationTimingFunction 指定动画的速度曲线。
animationDelay 规定动画开始的延迟时间。
animationIterationCount 规定动画的播放次数。
animationDirection 规定是否循环交替反向播放动画。
animationFillMode 规定当动画不播放时(当动画完成时,或当动画有一个延迟未开始播放时),要应用到元素的样式。
animationPlayState 规定动画是运行的还是暂停的。
initial 设置该属性为它的默认值。请参阅 initial。
inherit 从父元素继承该属性。请参阅 inherit。

技术细节

默认值: none 0 ease 0 1 normal none running
返回值: 字符串,表示元素的 animation 属性。
CSS 版本 CSS3


相关文章

CSS 参考手册:animation 属性


Style 对象参考手册 Style 对象

温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

HTML DOM对象

HTML DOM 引用对象

HTML DOM Password 对象

HTML DOM Link 对象

HTML DOM Select 对象

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }