2011-02-09 55 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>