Flexible DIV height on different page sizes - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Height

Description

Flexible DIV height on different page sizes

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
body {<!-- w  ww  .  j  ava 2  s.co  m-->
   margin:0;
   height:100%;
}

#mainContainer {
   position:absolute;
   right:5%;
   left:5%;
   height:100%;
}

#headerContainer {
   width:100%;
   position:relative;
   background:Chartreuse;
   color:yellow;
   height:11%;
}

#middleContainer {
   height:81%;
}

#leftSection {
   position:absolute;
   float:left;
   width:176px;
   background:blue;
   height:81%;
   overflow:auto;
   color:pink;
}

#middleSection {
   position:absolute;
   height:81%;
   background-color:WhiteSmoke;
   left:176px;
   right:176px;
   color:OrangeRed;
}

#rightSection {
   float:right;
   height:81%;
   width:176px;
   border-left:2px dotted grey;
   background:red;
   color:BlueViolet;
}

#footerContainer {
   position:relative;
   width:100%;
   height:11%;
   background:Chartreuse;
   color:yellow;
}
</style> 
 </head> 
 <body> 
  <div id="mainContainer"> 
   <div id="headerContainer">
     headerContainer 
   </div> 
   <div id="middleContainer"> 
    <div id="leftSection"> 
     <div style="margin-top: 30px;">
       leftSection 
     </div> 
    </div> 
    <div id="middleSection"> 
     <div style="margin-top: 30px;">
       middleSection 
     </div> 
    </div> 
    <div id="rightSection"> 
     <div style="margin-top: 30px;">
       rightSection 
     </div> 
    </div> 
   </div> 
   <div id="footerContainer">
     footerContainer 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials