Use image to cover background with background-size:cover - HTML CSS CSS Property

HTML CSS examples for CSS Property:background

Description

Use image to cover background with background-size:cover

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">

.test {<!--from  w  w  w . jav a2 s  .c  om-->
   width: 250px;
   height: 150px;
   background: url("https://www.java2s.com/style/demo/InternetExplorer.png") no-repeat left top;
   background-size: cover;
}


      </style> 
 </head> 
 <body> 
  <div class="test"></div>  
 </body>
</html>

Related Tutorials