How can I create a child div
that fills 100% of the parent's width and height, including padding? I've tried using box-sizing = border-box
, but it isn't working. I also attempted adding the box-sizing property to all elements with *
, but that didn't change anything either.
Here is my code snippet:
html {
font-size: 16px;
}
.parent {
font-size: 1rem;
width: 10em;
height: 10em;
padding: 5em;
background-color: #f0f0f0;
}
.child {
background-color: #ccc;
width: 100%;
height: 100%;
/*
--= 100% should include padding =--
box-sizing: border-box; <-- this didn't change anything...
*/
}
<div class="parent">
<div class="child"></div>
</div>