CSS Horizontally align text over image - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text Alignment

Description

CSS Horizontally align text over 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">
#wrapper {<!--from  ww  w.j  av  a  2 s. c  om-->
   width:100%;
   position:relative
}

.txt {
   position:absolute;
   text-align:center;
   margin:0 auto;
   width:41px;
   background-color:Chartreuse;
   z-index:100;
   width:100%;
}

img {
   height:31px;
   width:100%;
}

.imageClass
 {
   position:absolute;
   left:0;
   top:0;
}
</style> 
 </head> 
 <body> 
  <div id="wrapper"> 
   <img class="imageClass" src="https://www.java2s.com/style/demo/InternetExplorer.png"> 
   <span class="txt">Lor</span> 
   <div id="module"> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials