Responsive Images using CSS background image - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

Responsive Images using CSS 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">
* {<!--  www .j  av a  2  s  . c om-->
   width:100%;
   height:100%;
}

#container {
   width:100%;
   height:51%;
   position:relative;
}

#d1 {
   position:absolute;
   height:17%;
   width:40%;
   bottom:0;
   left:0;
   background-color:Chartreuse;
   opacity:0.8;
   color:yellow;
}

#d2 {
   position:absolute;
   height:69%;
   width:30%;
   top:0;
   left:59%;
   background-color:blue;
   opacity:0.8;
   color:pink;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <img src="https://www.java2s.com/style/demo/Google-Chrome.png" border="0" alt="Image and video hosting by TinyPic"> 
   <div id="d1">
     Lorem 
   </div> 
   <div id="d2">
     Lorem ipsum 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials