vertically center text overlapping an image - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text

Description

vertically center text overlapping an image

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">
.image {<!-- w  w  w . j ava  2 s .co m-->
   position:relative;
   width:26%;
   text-align:center;
}

img {
   width:100%;
}

p.info {
   position:absolute;
   width:100%;
   z-index:11;
   line-height:100%;
}
</style> 
 </head> 
 <body> 
  <div class="column"> 
   <div class="image"> 
    <img src="https://www.java2s.com/style/demo/Google-Chrome.png"> 
    <p class="info">Lorem <br> <span>Lorem ipsum </span> </p> 
   </div> 
   <div class="image"> 
    <img src="https://www.java2s.com/style/demo/InternetExplorer.png"> 
    <p class="info">Lorem ipsum<br> <span>Lorem ipsum </span> </p> 
   </div> 
   <div class="image"> 
    <img src="https://www.java2s.com/style/demo/Safari.png"> 
    <p class="info">Lorem ip<br> <span>Lorem ipsum </span> </p> 
   </div> 
   <div class="image"> 
    <img src="https://www.java2s.com/style/demo/Safari.png"> 
    <p class="info">Lorem<br> <span>Lorem ipsum </span> </p> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials