Child element's percentage-based size calculated when its parent has padding - HTML CSS CSS Property

HTML CSS examples for CSS Property:padding

Description

Child element's percentage-based size calculated when its parent has 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">
div.parent {<!--from   ww w .j  a v a  2s  .c  o m-->
   background-color:Chartreuse;
   padding-left:21px;
   padding-right:21px;
   width:201px;
   height:201px;
}

div.child {
   background-color:yellow;
   width:51%;
   height:51%;
}
</style> 
 </head> 
 <body> 
  <div class="parent"> 
   <div class="child"> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials