Centering table in a div - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Div Table

Description

Centering table in a div

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">
#outer {<!--   w  w w.  j av a  2  s .  c o m-->
   width:201px;
   background:pink;
   position:relative;
}

#inner {
   display:table-cell;
   vertical-align:middle;
   padding:3em;
   background:gray;
   position:absolute;
   right:0;
}

table {
   background:gold
}
</style> 
 </head> 
 <body> 
  <div id="outer"> 
   <div id="inner"> 
    <table> 
     <tbody> 
      <tr> 
       <td>Lor</td> 
       <td>Lor</td> 
      </tr> 
      <tr> 
       <td>Lor</td> 
       <td>Lor</td> 
      </tr> 
     </tbody> 
    </table> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials