make a percentual width to include the padding - HTML CSS CSS Property

HTML CSS examples for CSS Property:width

Description

make a percentual width to include the padding

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 {<!--   www .  j  a  v  a2  s  .c om-->
   width: 500px;
}
.container .image-wrapper {
   width: 50%;
   padding: 0 20px; 
   -webkit-box-sizing: border-box;
   -moz-box-sizing: border-box;
   box-sizing: border-box;  
}
.container .image-wrapper img {
   width: 100%;
   height: 100%;
}


      </style> 
 </head> 
 <body> 
  <div class="container"> 
   <div class="image-wrapper"> 
    <img src="https://www.java2s.com/style/demo/Opera.png"> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials