我在一个容器中有 2 个容器..我需要设置左容器和右容器的背景颜色,但下面的代码不起作用...
fiddle
http://jsfiddle.net/4uG4j/
html
<div id="container">
<div id="left-container">
</div>
<div id="right-container">
</div>
</div>
css
html,body{
height:100%;
width:100%;
margin:2;
}
#container{
height:75%;
background-color:yellow
}
#left-container{
width:23%;
background-color:red;
float:left;
border:1px solid #254117;
}
#right-container{
width:75%;
background-color:green;
float:left;
}
最佳答案
It does work ,您只是没有内容,导致元素的 height
为零。
关于html - div over div 的背景色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24289084/