I am using the backstretch jquery plugin with multiple divs as backgrounds (sections.) Currently I am using fixed heights but I want the divs to be 100% height of the window and the page to be scrollable. How can I accomplish this?
HTML
<div class="main-container"></div>
<div class="main-container2"></div>
<div class="main-container3"></div>
<div class="main-container4"></div>
CSS
.main-container {
background-image:url(../images/footballfieldblur.jpg);
height:1000px;
z-index:-100;
}
.main-container2 {
background-image:url(../images/orange3.png);
height:1000px;
}
.main-container3 {
background-image:url(../images/lightbackground.jpg);
height:1000px;
}
.main-container4 {
background-image:url(../images/diamondplatebackground.jpg);
height:1000px;
}
JAVASCRIPT
<script>
$(".main-container").backstretch("images/footballfieldblur.jpg");
$(".main-container2").backstretch("images/orange3.png");
$(".main-container3").backstretch("images/lightbackground.jpg");
$(".main-container4").backstretch("images/diamondplatebackground.jpg");
</script>
You could use in html and body:
Height:100%;
or
Min-height:100%
or use javascript:
$(".main-container").css({'height':($(document).height())+'px'});
body{
height:100%;
overflow:scroll;
}
.main{
height:100%;
}
Does this solve your problem: http://jsfiddle.net/David_Knowles/Q3HWT/
<div class="main-container column"></div>
<div class="main-container2 column"></div>
<div class="main-container3 column"></div>
<div class="main-container4 column"></div>
html, body {position:relative; height: 100%; padding: 0; margin: 0; }
.column {position:absolute; top: 0; bottom: 0; left: 0; right: 0;}
just add following to CSS style section :
<style>
* { margin : 0 ; padding : 0 ; }
</style>
Hope will be helpful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.