2
#outer
和#inner
必须都是position:absolute
或fixed
。绝对定位的子元素溢出父容器
如何可以有这样的,使得在所述#inner
100%
值是相对于#outer
的宽度减去它的填充(例如,像一帧),而不是具有#inner
溢出?
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>