html - Vertical div expansion w/o fixed heights -
before roll eyes , move on, know how solve problem using fixed height , absolution positioning top: , bottom:, want solve without using fixed heights. want learn more css i'm trying solve different way.
i have set typical navbar running across top, , scrolling content div below.
however! how fit bottom scrolling div container remaining space without using absolute coordinates? can't position: absolute, because i'd need know height of navbar set "top:". , can't "bottom: 0" because i'd have specify height.
here's js filddle:
http://jsfiddle.net/8dugffz4/1/
the class of interest ".result". have height fixed, don't want.
thanks, y'all. pt
css:
* { font-family: helvetica, sans; border: 0px; margin: 0px; padding: 0px; } .navbar { width: auto; overflow: auto; border-bottom: 1px solid #bbb; } .pagebar { float: right; } .pager { cursor: pointer; float: left; border: 1px solid #bbb; width: 2em; height: 2em; line-height: 2em; text-align: center; margin: 5px; margin-left: 0px; background: #eee; color: #bbb; } .pager:hover { background: #777; border: 1px solid black; color: white; } .fliph { -ms-transform:scale(-1,1); /* ie 9 */ -moz-transform:scale(-1,1); /* firefox */ -webkit-transform:scale(-1,1); /* safari , chrome */ -o-transform:scale(-1,1); /* opera */ } .results { background: gray; width: 100%; height: 200px; overflow: scroll; } .line { height: 10em; line-height: 10em; border: 1px solid red; }
html:
<body> <div class='navbar'> <div class='pagebar'> <div class='pager'>◁</div> <div class='pager'>1</div> <div class='pager fliph'>◁</div> </div> </div> <div class='results'> <div class='line'>line1</div> <div class='line'>line2</div> <div class='line'>line3</div> <div class='line'>line4</div> </div> </body>
here's solution uses display: table
, can achieve fluid heights:
http://jsfiddle.net/8dugffz4/8/
and minimalistic snippet in case want see did:
* { margin: 0; padding: 0; } html, body { height: 100%; } #table { display: table; height: 100%; width: 100%; } #table > div { display: table-row; } #navbar { height: 45px; opacity: .5; } #navbar > div { height: 100%; background: black; } #results { height: 100%; } #results > div { height: 100%; overflow: auto; background: green; }
<div id="table"> <div id="navbar"> <div></div> </div> <div id="results"> <div></div> </div> </div>
Comments
Post a Comment