#outer
and #inner
must both be position:absolute
or fixed
.
How can I have this so that the 100%
values in #inner
are relative to #outer
's width minus its padding (e.g., like a frame) and not have #inner
overflow?
html, body {
height: 100%;
margin: 0;
width: 100%;
}
#outer {
background: red;
height: 50%;
padding: 20px;
position: absolute;
width: 50%;
}
#inner {
background: yellow;
height: 100%;
position: absolute;
width: 100%;
}
<div id="outer">
<div id="inner"></div>
</div>