用这个setInterval()
var time=function(){你写的代码}
setInterval(time,1000)
| 值 | 描述 || animation-name | 规定需要绑定到选择器的 keyframe 名称。。 |
| animation-duration | 规定完成动画所花费的时间,以秒或毫秒计。 |
| animation-timing-function | 规定动画的速度曲线。 |
| animation-delay | 规定在动画开始之前的延迟。 |
| animation-iteration-count | 规定动画应该播放的次数。 |
| animation-direction | 规定是否应该轮流反向播放动画。 |
animation-fill-mode : none | forwards | backwards | both
/*none:不改变默认行为。
forwards :当动画完成后,保持最后一个属性值(在最后一个关键帧中定义)。
backwards:在 animation-delay 所指定的一段时间内,在动画显示之前,应用开始属性值(在第一个关键帧中定义)。
both:向前和向后填充模式都被应用。 */
transform 属性向元素应用 2D 或 3D 转换。该属性允许我们对元素进行旋转、缩放、移动或倾斜。
transform-origin: bottom right/* 设置旋转点,默认是中心点 */
参考
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
body{
background: url(img/fstpage1.jpg)
}
</style>
<script type="text/javascript">
var imgs=["fstpage1.jpg","fstpage2.jpg","fstpage3.jpg"]
setInterval(function(){
document.getElementsByTagName("body")[0].style.backgroundImage="url(img/"+imgs[parseInt(Math.random()*3)]+")"
},5000)
</script>
</head>
<body>
</body>
</html>