Align div to page center with dynamic size - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Div Align

Description

Align div to page center with dynamic size

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

body {<!--from   w  w w .ja  v  a 2  s.co m-->
   background-color:Chartreuse;
   overflow:hidden;
   font-family:"Helvetica";
   color:yellow;
   font-weight:bold;
   display:table;
}

#container {
   background-color:blue;
   height:100%;
   width:100%;
   margin:0;
   text-align:center;
   vertical-align:middle;
   display:table-cell;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <span class="currency">$ </span> 
   <span class="integer">4,080.</span> 
   <span class="decimal">00</span> 
  </div>  
 </body>
</html>

Related Tutorials