<分区>
<分区>
Possible Duplicate:
Maximize a floating div?
我有这个 HTML 代码:
<div id="container">
<div id="sidebar">
left
<br /><br /><br /><br /><br /><br />
</div>
<div id="content">
right
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
bla bla
</div>
<div class="clear"></div>
</div>
这是CSS代码:
#container {
width: 760px;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
overflow: hidden;
background: #ffffff;
border: 1px solid #cdcdcd;
}
#sidebar {
float:left;
width:25%;
background:#555;
}
#content {
float:left;
width:75%;
background:#eee;
}
.clear {
clear: both;
}
不幸的是,侧边栏的高度与 cointaner 的高度不同,我该如何扩展它的高度?
谢谢
最佳答案
可能不是您要找的东西,但试试这个:
<style>
#container {
width: 760px;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
overflow: hidden;
background: #ffffff;
border: 1px solid #cdcdcd;
position: relative; //Makes the children in the container positionable
}
#sidebar {
bottom: 0px; //position side bar.
left: 0px; //position side bar.
top: 0px; //position side bar.
width:25%;
background:#555;
position: absolute
}
#content {
margin-left: 25%;
width:75%;
background:#eee;
}
.clear {
clear: both;
}
</style>
<div id="container">
<div id="sidebar">
left
<br /><br /><br /><br /><br /><br />
</div>
<div id="content">
right
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
bla bla
</div>
<div class="clear"></div>
</div>
关于html - 如何在内部DIV中设置相同的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10436649/