For the given CSS below, why is child more than 10px as I've specified 100%. Also shouldn't child start from left:0 and top:0. Why is it starting from left:20px and top: 20px ?
My understanding about absolute position is that, it's position and sizing will be relative to a parent that's positioned. Here parent is static. Therefore it fallbacks to root i.e., body for sizing and positioning. Why does the child respects padding of parent ?
body {
border: 0.1em solid;
height: 10px;
}
.parent {
padding: 20px;
}
.child {
position: absolute;
border: 0.1rem solid;
height: 100%;
}
<div class="parent">
<div class="child"></div>
</div>