Position a text over image containing div - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text Position

Description

Position a text over image containing div

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>Lorem ipsum dolor sit</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.parent-div {<!--from   w w w .ja  v a  2s  .  c o m-->
   margin-top:51px;
   max-width:351px;
   background-color:Chartreuse;
   position:relative;
   height:401px;
   z-index:-2;
}

img {
   max-height:100px;
   z-index:-2;
}

.image-holder-div {
   position:absolute;
   right:-16px;
   top:-16px;
   background-color:yellow;
   padding:16px;
   z-index:-2;
}

.parent-div p {
   z-index:10000;
}
</style> 
 </head> 
 <body> 
  <div class="parent-div"> 
   <div class="image-holder-div"> 
    <img src="https://www.java2s.com/style/demo/Google-Chrome.png"> 
   </div> 
   <p>Lorem ipsum dolor sit amet, consectetur adipisci</p> 
   <p>Lorem ipsum dolor sit amet, consectetur ad</p> 
  </div>  
 </body>
</html>

Related Tutorials