I'm in a confusion since yesterday. Actually I have a markup as follows:
<div class="container">
<div class="child>
<div class="descendant">Content</div>
</div>
</div>
And CSS:
.container {
max-width: 500px;
min-width: 100px;
}
The .container
element has some width between 100px
to 500px
according to my content and the child & descendant elements have some other content without any specific width
or min/max-width
.
What happens is that when I apply horizontal padding to .container
, its content-box
size remains as is & just padding
is added to it. But whenever I apply horizontal padding to any of the child or descendant elements, they do not add padding to their size or the parent's size. Instead, their content-box
size reduces and they accommodate padding
.
I seriously can't get what is going on here. Can anyone explain me what's actually happening?