【发布时间】:2015-09-26 18:36:58
【问题描述】:
我需要每隔 3000 毫秒(带有淡入/淡出效果)在几个 div 中随机更改背景图像
- 我有 4 个 div,每个 div 都有背景图片
- 所有图像都来自一个数组
我该怎么做?
这是我的小提琴:
http://jsfiddle.net/vol4ikman/brrmkwp7/9/
var images = [
"http://placehold.it/100x100",
"http://lorempixel/100/100",
"http://lorempixel/100/100",
"http://lorempixel/100/100",
"http://lorempixel/100/100",
"http://lorempixel/100/100",
"http://lorempixel/100/100",
"http://lorempixel/100/100",
"http://lorempixel/100/100"
];
.images_wrapper {
width:600px;
position:relative;
margin: 0 auto;
min-height:300px;
background:silver;
padding:20px;
}
.images_wrapper > div {
width:100px;
height:100px;
overflow:hidden;
position:relative;
margin:10px;
background-color:#FFF;
border:1px solid #000;
border-radius:50%;
}
<div class="images_wrapper">
<div class="image-holder image-1"></div>
<div class="image-holder image-2"></div>
<div class="image-holder image-3"></div>
<div class="image-holder image-4"></div>
</div>
【问题讨论】:
-
我会使用 jquery,这看起来非常相似:stackoverflow.com/questions/3181861/…
标签: javascript jquery html css slideshow