html - div height overflowing parent div -


i need 2 bottom divs take reminder of height without overflowing past parent div. if 2 bottom divs have content them overflow:scroll , scroll content of div. page should if body has overflow:hidden

html

<body> <div class="mainwrapper">     <div class="mainheader">         header     </div>     <div class="mainnav">         nav     </div>     <div class="maincontent">         text     </div> </div> 

css

html{    height: 100%; } body {    background-color: #69a8ca;    background-repeat: no-repeat;    background-position: 0 100%;    margin-top: 2px;    margin-bottom: 2px;    height:99%;    overflow:hidden; }  .mainwrapper{    height:100%; } .mainnav, .maincontent{    height: 100%;    margin-top: 5px; }  .mainheader{    display:block;    text-align:center;    height: 150px;    background:red; }  .mainnav{    float:left;    width: 100px;    background: blue; }  .maincontent{    background: green; } 

http://jsfiddle.net/dj52b0d7/

with current code, apply css:

html { height: 100%; } body { background-color: #69a8ca; background-repeat: no-repeat; background-position: 0 100%; margin-top: 2px; margin-bottom: 2px; height:100vh; } .mainwrapper { height:100%; } .mainnav, .maincontent { height: calc(100vh - 160px); margin-top: 5px; overflow:auto; } .mainheader { display:block; text-align:center; height: 150px; background:red; } .mainnav { float:left; width: 100px; background: blue; } .maincontent { background: green; } 

see fiddle here


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -