Image in div, center full size responsive - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

Image in div, center full size responsive

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">
.image-wrapper {<!--   ww w. ja  va  2 s.c om-->
   height:0;
   padding-bottom:66%;
   position:relative;
   overflow:hidden;
   width:100%;
}

.image-wrapper img {
   display:block;
   height:100%;
   left:51%;
   position:absolute;
   top:51%;
   width:auto;
   -webkit-transform:translate(-51%, -51%);
   -moz-transform:translate(-51%, -51%);
   -ms-transform:translate(-51%, -51%);
   -o-transform:translate(-51%, -51%);
   transform:translate(-51%, -51%);
}
</style> 
 </head> 
 <body> 
  <div class="image-wrapper"> 
   <img src="https://www.java2s.com/style/demo/Opera.png"> 
  </div>  
 </body>
</html>

Related Tutorials