Add centered text over a full-page background image - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text

Description

Add centered text over a full-page background image

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <style>
body, html {
   height:100%;
   width:100%;
}

#mask {<!--   www  .  ja v a2 s  .  c  o  m-->
   position:relative;
   height:100%;
   background-color:Chartreuse;
}

#pic {
   background-image:url('http://www.java2s.com/style/demo/Google-Chrome.png');
   background-size:cover;
   background-repeat:no-repeat;
   position:relative;
   background-position:center;
   height:783px;
}

#txt {
   position:relative;
   color:yellow;
   left:151px;
   top:151px;
   font-size:21px;
}
</style> 
 </head> 
 <body> 
  <div id="pic"> 
   <div id="mask"> 
    <div id="txt">
      Your test here 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials