Center element within another, while parent specifies position: absolute - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

Center element within another, while parent specifies position: absolute

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">
.dotParent {<!--   ww  w  .j ava 2s.  co  m-->
   position:relative;
   top:151px;
   left:51px;
   height:69px;
   width:69px;
   border:2px solid Chartreuse;
}

.dot {
   position:absolute;
   width:11px;
   height:11px;
   border-radius:51%;
   background:yellow;
   -webkit-border-radius:51px;
   left:46%;
   top:46%;
}
</style> 
 </head> 
 <body> 
  <div class="dotParent"> 
   <div class="dot"></div> 
  </div>  
 </body>
</html>

Related Tutorials