Responsive DIV scaling within "background-size: contain" image - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

Responsive DIV scaling within "background-size: contain" 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">
html, body {
   width:100%;
   height:100%;
   min-width:326px;
   background:Chartreuse url('https://www.java2s.com/style/demo/Google-Chrome.png') center center no-repeat;
   background-size:contain;
   margin:0 auto;
   overflow-x:hidden;
   background-size:100% 100%;
}

.wrapper {<!--from www  . j  a v a 2  s  .co m-->
   width:100%;
   height:100%;
}

.navbar {
   position:relative;
   width:100%;
   height:15%;
   top:76%;
   margin:0 auto;
   border:2px solid yellow;
}

#home {
   position:absolute;
   top:0;
   left:16%;
   width:16%;
   height:100%;
   display:block;
   border:2px solid blue;
}
</style> 
 </head> 
 <body> 
  <div class="wrapper"> 
   <div class="navbar"> 
    <div id="home"></div> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials