Centering a div with absolute positioning - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

Centering a div with absolute positioning

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">
.container {<!--from   w  ww . j  av a2  s  .c  om-->
   position:relative;
   background:Chartreuse;
   width:301px;
   height:301px;
}

a.logo {
   position:absolute;
   display:block;
   height:151px;
   width:151px;
   background:yellow;
   right:26%;
   top:26%
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <a href="#" title="logo" class="logo">Lore</a> 
  </div>  
 </body>
</html>

Related Tutorials