HTML/CSS: Text overlay on a background image - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text

Description

HTML/CSS: Text overlay on a background 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">
.mainPage {<!--  w  ww . j a va 2 s .  c  om-->
   background:red;
   width:100%;
   float:left;
}

.main-content {
   background:yellow url('https://www.java2s.com/style/demo/Google-Chrome.png')
   no-repeat center;
   width:601px;
   height:451px;
   margin:0 auto;
}

.text-content {
   text-align:center;
   color:Chartreuse;
   padding-top:51px;
}
</style> 
 </head> 
 <body> 
  <div class="mainPage"> 
   <div class="main-content"> 
    <div class="text-content"> 
     <div class="text-body">
       Lorem ipsum do 
     </div> 
     <div class="text-body">
       Lorem ipsum do 
     </div> 
     <div class="text-body">
       Lorem ipsum do 
     </div> 
    </div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials