Position relative div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Relative Position

Description

Position relative 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">
#img {<!-- w  w w  . j  a v  a2s  .  c  om-->
   float:left;
   margin:6px;
   padding:0;
   width:201px;
   height:201px;
   text-align:center;
   font-size:2em;
   position:relative;
   background-color:Chartreuse;
   border:2px solid yellow;
}

#imgOver {
   position:absolute;
   top:0;
   width:201px;
   height:201px;
   background-color:blue;
   color:pink;
}
</style> 
 </head> 
 <body> 
  <div id="img"> 
   <img src="https://www.java2s.com/style/demo/InternetExplorer.png" height="200"> 
   <div id="imgOver">
     Lorem 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials