我在容器 div 中有一个 绝对定位
div。绝对定位的 div 的背景色没有填充容器 div。容器 div 的高度根据内容是动态的。如何使定位的 div 的背景颜色填充它的容器 div?
HTML:
<div class="container">
test<br />
test<br />
test<br />
<div class="showbg">
test
</div>
</div>
CSS:
.container{ background-color:#CCCCCC; width:300px;}
.showbg{ background-color:#FFFFFF; position:absolute; width:300px; margin-top:-65px; opacity:0.4;
filter:alpha(opacity=40);}
最佳答案
.container {position: relative;}
.showbg {position:absolute; top:0;bottom:0;left:0;right:0;}
关于html - 绝对位置div不填充容器div css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20298783/