Stop background overflowing outside of its width/height with background-size: contain - HTML CSS CSS Property

HTML CSS examples for CSS Property:background-size

Description

Stop background overflowing outside of its width/height with background-size: contain

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">
div {<!--from   w w  w.  j  a va 2 s. co  m-->
   background:url('https://www.java3s.com/style/demo/Google-Chrome.png') no-repeat center center;
   background-size:contain;
   height:201px;
}
</style> 
 </head> 
 <body> 
  <div> 
  </div>  
 </body>
</html>

Related Tutorials