javascript - Div to take entire height of viewport, until scroll to next div -
i have 5 div containers. want render first div entire height of viewport. , on scroll, next div takes on entire height of viewport. how this?
html code:
<div class="wrapper"> <div id="first-container" > <p> hello </p> </div> <div id="second-container"> <p> hello </p> </div> <div id="third-container"> <p> hello </p> </div> <div id="four-container"> <p> hello </p> </div> <div id="five-container"> <p> hello </p> </div> </div>
i found simple css code. works on first div doesn't allow me scroll next div.
#first-container{ position: fixed !important; position: absolute; top:0; right:0; bottom:0; left:0; } #second-container{ background-image: url("blue-gradient.png"); } #third-container{ background-color: #a8ceff; } #four-container{ background-image: url("green-gradient.png"); } #five-container{ background-color: #394457; }
set html
, , body
height: 100%
, apply height: 100%
sections. this:
html
<div class="wrapper"> <section> content 1 </section> <section> content 2 </section> <section> content 3 </section> <section> content 4 </section> <section> content 5 </section> </div>
css
body, html { height: 100%; width: 100%; } section { height: 100%; width: 100% }
Comments
Post a Comment