css - DIVs inside DIV height issue -


problem

i'm trying make similar image below, black body id="library", grey div id="body" (is not visible due lack of margins inner divs), light blue div id="sidebar", red div id="content", blue div id="navbar" , green div id="contentwindow".

image: http://i.imgur.com/wplyfqj.png?1

i'm having trouble containing green div inside red div (the greens parent). configure greens margins respect red div , not have set height explicitly. implementation:

http://jsfiddle.net/efntl/

i divs adjust screen width , height visible @ times (down small browser windows).

i've looked @ following links haven't provided useful:

resizable div inside div 100% height margin around not working well! please?

how push div inside div structure?

parent div expand children div

the code can seen in fiddle above i've included here:

html

<body class="library"> <div id=body>     <div id="sidebar">         <p>hej</p>         <p>hej</p>         <p>hej</p>         <p>hej</p>     </div>      <div id="content">                 <div id="navbar">             <p>hey</p>         </div>          <div id="contentwindow">                 <p>hej</p>         </div>       </div>       </div> </body> 

css

body.library, html {     background:black;     height:100%;     margin: 0;      padding: 0;      border: 0 none; }  div#body {      /*display:block;*/     background:#e6e6e6;     max-width:400px;     display:block;     height:90%;     margin-top:20px;     margin-bottom:20px;     margin-left:auto;     margin-right:auto;   }  div#sidebar{     /*display:block;     position:relative;*/     background:#94dbff;     float:left;     width:50px;     height:100%;     }  div#content{     /*display:block;     position:relative;*/     background:#ff0000;      min-width:70px;     margin-right:0px;     margin-left:50px;     margin-top:0px;     margin-bottom:0px;     height:100%; }  div#contentwindow{     display: block;     position:relative;     height:auto;     bottom:0;     top:0;     left:0;     right:0;     margin-top:20px;     margin-bottom:20px;     margin-right:80px;     margin-left:80px;     background-color: green;     height:100%;     overflow:auto; }  div#navbar {     list-style-type:none;     margin:0;     padding:0;     overflow:hidden;     text-align:center; } 

if navbar has fixed height might work you:

body.library, html {     background:black;     height:100%;     margin: 0;      padding: 0;      border: 0 none; }  div#body {      /*display:block;*/     background:#e6e6e6;     max-width:400px;     display:block;     height:90%;     margin-top:20px;     margin-bottom:20px;     margin-left:auto;     margin-right:auto;   }  div#sidebar{     /*display:block;     position:relative;*/     background:#94dbff;     float:left;     width:50px;     height:100%;     }  div#content{     display:block;     position:relative; //position relative contain absolutely positioned element     background:#ff0000;      min-width:70px;     margin-right:0px;     margin-left:50px;     margin-top:0px;     margin-bottom:0px;     height:100%; }  div#contentwindow{     display: block;     position:absolute; //set position absolute     height:auto;     bottom:0;     top:0;     left:0;     right:0;     margin-top:50px; //increase margin top have navbar visible     margin-bottom:20px;     margin-right:20px;     margin-left:20px;     background-color: green; }  div#navbar {     list-style-type:none;     margin:0;     padding:0;     overflow:hidden;     text-align:center; } 

check out fiddle - http://jsfiddle.net/taneleero/8tqkw/


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -