HTML CSS examples for CSS Widget:Table Cell
Use table-cell layout to place div in the middle of a page
<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; } .table {<!-- w w w.ja v a 2 s . com--> width:100%; height:100%; display:table; } .table-cell { display:table-cell; background-color:Chartreuse; vertical-align:middle; text-align:center; } .content { background-color:yellow; width:501px; height:301px; margin:0 auto; text-align:left; color:blue; display:table; vertical-align:middle; } .article { display:table-cell; vertical-align:middle; padding:21px; } </style> </head> <body> <div class="table"> <div class="table-cell"> <div class="content"> <div class="article"> <h2>Lorem</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat.</p> </div> </div> </div> </div> </body> </html>