html - How can I make DIV 100% height of browser without vertical scrolling of header -
both left , right panels have height of 100%, since header div takes x amount of space, there vertical scrolling in window want rid of.
how can remove vertical scrolling?
jsfiddle: http://jsfiddle.net/g7ung/1/
css , html
html, body{ height: 100%; margin: 0; } .header{ background: #333; padding: 15px; text-align:center; font-size: 18px; font-family: sans-serif; color: #fff; } .leftpanel, .rightpanel{ height: 100%; } .leftpanel{ float: left; width: 70%; background: #ccc; } .rightpanel{ float: left; width: 30%; background: #666; } <div class="header">header</div> <div class="leftpanel">left panel</div> <div class="rightpanel">right panel</div> <div class="clearfix"></div>
here's modern solution using flexbox. regardless of height of header rest of elements stretch vertically fill remaining space. here's fiddle: http://jsfiddle.net/mggly/1/.
html:
<div id = "wrapper"> <div class="header">header</div> <div> <div class="leftpanel">left panel</div> <div class="rightpanel">right panel</div> </div> </div> css:
* { margin: 0; padding: 0; border: 0; } html, body { height: 100%; } .header{ background: #333; padding: 15px; text-align:center; font-size: 18px; font-family: sans-serif; color: #fff; } .leftpanel{ background: #ccc; } .rightpanel{ background: #666; } #wrapper { height: 100%; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; outline: 1px solid red; } #wrapper > .header { -webkit-flex: 0 0 auto; flex: 0 0 auto; } #wrapper > .header + div { -webkit-flex: 1 1 auto; flex: 1 1 auto; display: -webkit-flex; display: flex; -webkit-flex-direction: row; flex-direction: row; } #wrapper > .header + div > div:first-of-type { -webkit-flex: 7 0 0; flex: 7 0 0; } #wrapper > .header + div > div:last-of-type { -webkit-flex: 3 0 0; flex: 3 0 0; }
Comments
Post a Comment