Make flex item consume available space in container - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex

Description

Make flex item consume available space in container

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 {
   width:100%;
   height:100%;
   margin:0;
}

#container {<!--from   w ww  .ja v  a  2s  .co  m-->
   display:flex;
   height:100%;
   background-color:Chartreuse;
}

.block {
   flex:2;
}

#left {
   background-color:yellow;
}

#center {
   display:flex;
   flex-direction:column;
   flex:2;
   flex-wrap:wrap;
}

#right {
   background-color:blue;
}

.flexContainer {
   flex:2;
   min-width:100px;
   max-width:51%;
   height:151px;
   background-color:pink;
   padding:11px;
}

.flexDiv {
   width:100%;
   height:100%;
   background-color:WhiteSmoke;
}

#canvasObject {
   flex:2;
   border:2px solid;
   background-color:OrangeRed;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <div id="left" class="block">
     Left 
   </div> 
   <div id="center" class="block"> 
    <canvas id="canvasObject">
      Your browser does not support Canvas. 
    </canvas> 
    <button type="button">Click!</button> 
   </div> 
   <div id="right" class="block">
     Right 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials