Move DIV to the left of the centre position - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Move DIV to the left of the centre position

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">
#red {<!--   ww  w  . j  a  v a  2  s .c om-->
   width:2px;
   margin:100px auto;
   background:red;
}

#blue {
   width:201px;
   background:blue;
   left:-51px;
   position:relative;
}
</style> 
 </head> 
 <body> 
  <div id="red"> 
   <div id="blue">
     Lorem ipsum 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials