Make img responsive and fill into a div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

Make img responsive and fill into a div

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">
.wrapper {<!-- w w  w .j a  v a2s  . c  o m-->
   width:201px;
   height:301px;
   background:red;
}

.inner-wrapper {
   width:0;
   height:100%;
}

.inner-wrapper img {
   height:100%;
}
</style> 
 </head> 
 <body> 
  <div class="wrapper"> 
   <div class="inner-wrapper"> 
    <img src="https://www.java2s.com/style/demo/Opera.png"> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials