Text overlaying image inside a div with a background image - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text

Description

Text overlaying image inside a div with 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">
section {<!--from w  w  w .  ja  v a2  s. c o m-->
   background:url('https://www.java2s.com/style/demo/Google-Chrome.png') repeat;
   height:1001px;
   position:relative;
}

div.block {
   position:absolute;
   padding:11px;
}

img {
   position:absolute;
   top:0;
   width:100%;
}
</style> 
 </head> 
 <body> 
  <section> 
   <img src="https://www.java2s.com/style/demo/Google-Chrome.png"> 
   <div class="block">
     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. Phasellus sed quam pharetra, tincidunt tortor in, pharetra nisl. Maecenas aliquam luctus mauris, vitae venenatis diam imperdiet vel. Donec tortor diam, pretium vitae nibh vitae, consectetur lacinia sem. Proin luctus facilisis volutpat. Ut semper sit amet purus quis ornare. Quisque lobortis neque vitae tempor iaculis. Aliquam erat volutpat. Mauris tincidunt eget lacus eget 
   </div> 
  </section>  
 </body>
</html>

Related Tutorials