Auto scale image to fit the rest of device height - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image

Description

Auto scale image to fit the rest of device height

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">
.container {<!--   ww  w .j  av a 2s.  co m-->
   height:100%;
   position:absolute;
   top:0;
   left:0;
   bottom:0;
   right:0;
   display:flex;
   flex-direction:column;
}

.container div:last-child {
   flex:2;
   background:url('http://www.java2s.com/style/demo/Google-Chrome.png') 0 0 no-repeat;
   background-size:contain;
}
</style> 
 </head> 
 <body> 
  <div class="container"> 
   <div> 
    <h2>Title</h2> 
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> 
   </div> 
   <div></div> 
  </div>  
 </body>
</html>

Related Tutorials