My question is so simple but rather problematic for me, if a parent div have padding and child's div width is 100%, child's div width is always shorter than its parent one. if i change child div as absolute div and parent div as relative, child's width is just equal to the parent's no matter padding and margin in parents. Like this:
.first {
background-color: yellow;
width: 100px;
height: 100px;
padding: 10%;
position: relative;
}
.second {
background-color: blue;
position: absolute;
width: 100%;
height: 100%;
opacity: 40%;
}
<div class="first">HI
<div class="second">
HELLO
</div>
</div>
Eventhough parent's position is totally relative, so you assume Child is totally dependent on '.first'div. So, I am assuming how is child width is calculated in this case?