CSS centering with absolute positioning - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

CSS centering with absolute positioning

Demo Code

ResultView the demo in separate window

<html>
 <head></head> 
 <body style="text-align: center;"> 
  <div style="position: relative; width: 100px; height: 100px; margin: 0 auto; background: red;"> 
   <div style="position: absolute; left: 0; top: 0;">
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi 
   </div> <!--  w  w  w. jav a2 s  .co  m-->
  </div> 
  <div style="position: absolute; left: 0; top: 0; width: 100px; height: 100px; background: blue;">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
  </div>  
 </body>
</html>

Related Tutorials