2011-02-09 121 views
1

jQuery newbie!jQuery.cycle更改div背景图片

我真的有麻烦让Cycle插件更改div的背景图片而不是循环播放幻灯片。我的div有其他内容,我不想改变。

是否有另一个插件,我应该用它来实现这个目标?最受赞赏的就是这个。

+0

向我们展示一些代码,也许我们可以帮助你。 – Thew 2011-02-09 17:40:54

回答

1

简化马歇尔推荐的方法:http://jsfiddle.net/petarsubotic/299Wr/

CSS

#wrapper { 
position: absolute; 
overflow:hidden; 
height: 333px; /* optional */ 
background: black; /* optional */ 
} 
#content { 
position:relative; 
z-index:999; 
float:left; 
background: rgba(0, 0, 0, 0.8); /* optional */ 
padding:1em; /* optional */ 
margin: 1em; /* optional */ 
color:white; /* optional */ 
} 
#bg_containers { 
position:absolute; 
} 

HTML

<div id="wrapper"> 
<div id="content"> 
The background image behind this can be any size, so although it may not cover your entire screen in this case, you can make it cover as much or as little of the screen as you like. Just adjust the size of the #bg_containers, and of course, you can also have the background tile if you like as well. 
</div> 
<div id="bg_containers" > 
<div><img src="http://www.australia.com/contentimages/about-landscapes-nature.jpg"/> </div> 
<div><img src="http://www.mtsu.edu/urban/images/urban1.jpg"/></div> 
</div> 
</div>