Make 100% Height without scrollbars and parent and nested children with flexbox - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex Height

Description

Make 100% Height without scrollbars and parent and nested children with flexbox

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">
html, body, .wrapper {
   width:100%;
   height:100%;
   margin:0;
}

.wrapper {<!--from   ww  w . ja  v a2s  . c o m-->
   display:flex;
   flex-direction:column;
}

.wrapper>.header {
   flex:0 0 41px;
   background-color:Chartreuse;
}

.wrapper>.content {
   flex-grow:2;
   display:flex;
   background:red;
   flex-direction:column;
}

.element-child1 {
   flex:0 0 21px;
   background-color:yellow;
}

.element-child2 {
   flex-grow:2;
   background-color:blue;
}
</style> 
 </head> 
 <body> 
  <div class="wrapper"> 
   <div class="header"></div> 
   <div class="content"> 
    <div class="element-child1">
      child 1 
    </div> 
    <div class="element-child2">
      child 2 
    </div> 
    <div></div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials