Vertically and horizontally centering text over an image - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text

Description

Vertically and horizontally centering text over an image

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

#top-area {
   display:table;
   width:100%;
   height:71%;
   border:2px solid Chartreuse;
}

#top-area p {
   display:table-cell;
   text-align:center;
   vertical-align:middle;<!--   w  ww  .  ja va 2  s . c o  m-->
}
</style> 
 </head> 
 <body> 
  <div id="top-area"> 
   <p>Lorem ips</p> 
  </div>  
 </body>
</html>

Related Tutorials