我正在尝试将子 div 放在其父 div 的顶部(包括其内容)
<div id="footer">
<div id="footer-container">
<div id="icon"></div>
</div>
</div>
#footer {
height:50px;
border-top:3px #666 solid;
margin-top:50px;
}
#footer-container {
height: 30px;
width: 300px;
margin-left: auto;
margin-right: auto;
margin-top: -15px;
}
#icon {
height:30px;
width:30px;
background-color:#666;
}
现在,如果内容<div id="icon">
是文本,它可以工作,但如果你在 div 中放置背景图像,它不会。有什么办法可以使这项工作?这也许可以更好地解释它
http://jsfiddle.net/4QxL7/
编辑道歉。它一直在工作。我将PNG用于中间有“空白”的图像,这使得父div中的边框(相同颜色)看起来像是越过了孩子的顶部,实际上它是落后。
谢谢你的帮助