Responsive absolute position to center of DIV - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

Responsive absolute position to center of DIV

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">
#box1 {<!--from w  w w.  j a v a2  s .co m-->
   display:block;
   background:red;
   background-size:100%;
   position:relative;
   padding-bottom:61%;
   overflow:auto;
}

#box2 {
   display:block;
   background:blue;
   position:absolute;
   height:71px;
   width:71px;
   right:51%;
   top:51%;
   margin:-36px -36px 0 0;
}
</style> 
 </head> 
 <body> 
  <div id="box1"> 
   <div id="box2"></div> 
  </div>  
 </body>
</html>

Related Tutorials