Layout div as table with display: table; - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Div Table

Description

Layout div as table with display: table;

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">
.hasFlex {<!--from ww w .  ja v  a2s . c  o  m-->
   display:table;
   table-layout:fixed;
   width:100%;
}

.box1 {
   display:table-cell;
}

.container {
   margin-bottom:11px;
}

body {
   padding:21px;
}

div {
   border:2px dashed Chartreuse;
}
</style> 
 </head> 
 <body> 
  <div class="container hasFlex"> 
   <div id="main" role="main" class="box1"> 
    <div class="innerBG">
      test test test test test test test test test test test test test test 
    </div> 
   </div> 
   <div id="sidebar" class="box1"> 
    <div class="innerBG">
      a bunch more stuff (divs, text, etc.) go here 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials