css - How to make a div scroll able when window height is reached -
i have developed template using bootstrap, following fiddle represents layout expected, want yellow area scroll able when content inside reaches window height, while right red panel remains fixed.
html
<div class="header"> header </div> <div class="content"> <div class="left-panel"> <div class="dummy-content"> results </div> <div class="dummy-content"> results </div> <div class="dummy-content"> results </div> <div class="dummy-content"> results </div> <div class="dummy-content"> results </div> <div class="dummy-content"> results </div> <div class="dummy-content"> results </div> </div> <div class="right-panel"> map </div> </div> <div class="footer"> footer </div>
css
body{ text-align:center; width:100%; height:100%; } .header{ background:black; color:#fff;} .left-panel{ background:yellow; overflow-y: scroll; float:left; width:50%; height:100%; } .dummy-content{ height:150px; } .right-panel{ background:tomato; height:100%; float:right; width:50%; } .footer{ background:grey; position:absolute; bottom:0; width:100%; } .content > div{ display:inline-block; vertical-align:top; } .content{ clear:both; }
my problem
- how make content inside scroll when content increase , once window height reached
- the footer should not overlap scroll able area when screen size changed
- is possible provide css fix only
you can use calc()
function , vh
units achieve desired output :
.left-panel{ background:yellow; overflow-y: scroll; float:left; width:50%; height:calc(100vh - 40px); }
Comments
Post a Comment