Rookie here .. I'm trying to make my static background become a carousel.. my current html looks something like this:
<body>
<div class="pageContent">
</div>
</body>
and my CSS:
body {
background: url('http://placehold.it/1600x1200') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
So I'd like to make the background now cycle images and stay responsive .. Can this be done easily using CSS3? or should I maybe wrap the contents of my html in a carousel with bootstrap? I wasn't able to find a good example of how to do this. Thanks in advance.
i ended up finding a page that had exactly what i was looking for:
Bootstrap carousel as website background
will refer you to http://untame.net/2013/04/twitter-bootstrap-carousel/ and about halfway down the page will show you how to make a bootstrap background carousel without coding any JQ except for:
amazing!
jsBin demo
I would do it using an
absolute
positionedDIV
overlaying thebody
. Fade in theDIV
with a new image, then set the same image tobody
and hide theDIV
like: (GRAY isBODY
, SOrange isDIV
)The increment of the current image Array is achieved by preincrementing
++counter
.The loop fix is than achieved using Remainder Operator
%
to prevent the counter from exceeding the number of images in Array.The loop itself is done inside
.fadeTo()
callback function by simply do a new iteration of theloopBg()
function.This is the needed CSS:
And the jQ:
Edit: If you want to keep the background changing but make the content scrollable, simply add
overflow:auto;
to#page
like in this demo: http://jsbin.com/huzayiruti/1/> Hi ! for that you have to work with "layers" and jquery, example:
and in the css you have put the code for align the div in front or back ... the jquery is like that :
*> remember is just example, you have to modify the code for work as you
example slider background
> regards I hope help you !