according to the MDN I have read "border-box tells the browser to account for any border and padding in the value you specify for width and height. If you set an element's width to 100 pixels, that 100 pixels will include any border or padding you added, and the content box will shrink to absorb that extra width"
but in my case i have set two div box:
<style type="text/css">
.container{
width: 300px;
height: 300px;
background: blue;
margin: auto;
}
.child{
width: 150px;
height: 150px;
background: yellow;
border: 2px solid red;
box-sizing: border-box;
padding: 200em;
}
</style>
<body>
<div class="container">
<div class="child">
<h1>test</h1>
</div>
</div>
</body>
I have set the container div box with 300px height and width, the child div with 150px height and width with border-box property, but after i have given a big padding value to the child div box with 200em
the container box is not shrunk to absorb the extra width. I am wondering why is that?