我有一个固定高度和背景颜色的 div - 你可以想象背景颜色不会延伸到 div 的整个高度。
在这个容器 div 中,我还有 4 个用于圆角的 div
。我已经包含了下面的代码。无论内容如何,如何使背景颜色延伸到容器 div 的底部?
#art2 {
margin-top: 15px;
margin-right: 10px;
float: right;
width: 485px;
background-color: #262626;
}
.art2boxtl {
background-image: url(../images/tlar2.png);
background-repeat: no-repeat;
height: 10px;
width: 9px;
}
.art2boxtr {
position: absolute;
right: 10px;
top: 15px;
background-image: url(../images/trar2.png);
background-repeat: no-repeat;
height: 10px;
width: 9px;
}
.art2boxbl {
position: absolute;
bottom: 0px;
background-image: url(../images/blar2.png);
background-repeat: no-repeat;
height: 11px;
width: 10px;
}
.art2boxbr {
position: absolute;
bottom: 0px;
right: 10px;
background-image: url(../images/brar2.png);
background-repeat: no-repeat;
height: 11px;
width: 10px;
}
<div id="art2">
<div class="art2boxtl"></div>
<div class="art2boxtr"></div>
CONTENT
<div class="art2boxbl"></div>
<div class="art2boxbr"></div>
</div>
position: absolute
。如果元素是float: left
或right
,那么这将是正确的方法。 - Pekka