Create div and aligned to the page center - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Div

Description

Create div and aligned to the page center

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">

.one{<!--   ww  w. jav  a  2 s. c  om-->
   width: 250px;
   position: absolute;
   left: 50%;
   top: 50%;
   margin-left: -100px;
   border:2px solid #0000ff;
}
.two{
   display: inline-block;
   border:2px solid #ff0000;
}
p{
   display: inline-block;
   background: #00ff00;
   margin: 0;
   word-break: break-all;
}


      </style> 
 </head> 
 <body> 
  <div class="one"> 
   <div class="two"> 
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials