CSS positioning relative to div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Relative Position

Description

CSS positioning relative to 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">
body, html {
   width:100%;
   height:100%;
   margin:0;
}

#main {<!--from   w w  w. j  av  a2  s .co m-->
   display:block;
   width:51%;
   height:51%;
   background-color:Chartreuse;
   position:relative;
}

img {
   position:absolute;
   width:6%;
}

#card1 {
}
#card2 {
   left:96%;
}
</style> 
 </head> 
 <body> 
  <div id="main"> 
   <img id="card1" src="https://www.java2s.com/style/demo/Safari.png" alt="KH"> 
   <img id="card2" src="https://www.java2s.com/style/demo/Opera.png" alt="9H"> 
  </div>  
 </body>
</html>

Related Tutorials