Div with unspecified width in absolute positioning - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Absolute Position

Description

Div with unspecified width in 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">
html * {<!--from w ww.java 2  s . c o  m-->
   margin:0;
}

body {
   color:Chartreuse;
   font:12px verdana,arial,helvetica,sans-serif;
}

#a1 {
   position:relative;
   margin:11px;
   border:2px solid yellow;
   overflow:hidden;
}

#a1 img {
   max-width:701px;
}

#a2 {
   position:absolute;
   right:6%;
   bottom:6%;
   border:2px solid blue;
   color:pink;
   font-size:3em;
   background:OrangeRed;
   padding:11px;
}
</style> 
 </head> 
 <body> 
  <div id="a1"> 
   <img src="https://www.java2s.com/style/demo/Safari.png"> 
   <div id="a2"> 
    <div>
      Lorem ipsum dolor sit amet, c 
    </div> 
    <hr> 
    <div>
      Lorem ipsum dolor 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials