Responsive background-image leaving white space when resized - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

Responsive background-image leaving white space when resized

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">
html, body {
   height:100%;
   width:100%;
}

#container {<!--from  www.  jav  a  2  s.  c om-->
   height:100%;
   width:100%;
}

#background-image {
   background-image:url('https://www.java2s.com/style/demo/Google-Chrome.png');
   height:321px;
   width:100%;
   display:block;
   background-size:contain;
   background-repeat:no-repeat;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <div id="background-image"></div> 
   <p>Lorem</p> 
  </div>  
 </body>
</html>

Related Tutorials