jQuery.cycle change div background image

≡放荡痞女 提交于 2019-12-11 12:49:01

问题


jQuery newbie!

I am having real trouble getting the Cycle plugin to change the background image of a div rather than cycle through slides. My div has other content which I don't want to change.

Is there another plugin out there that I should be using to achieve this? Help most appreciated on this.


回答1:


This page should help you:

http://www.magneticwebworks.com/jquery-rotating-page-background/




回答2:


Simplifying the method Marshall recommended: 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>


来源:https://stackoverflow.com/questions/4948395/jquery-cycle-change-div-background-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!