我不确定DIV
的属性是否完全清晰。请注意,这不是一个答案(还没有),只是太长了无法放在评论中。
<div id="container">
<div id="list">
<ul></ul>
</div>
<div id="content">
<span>TEST CONTENT</span>
</div>
</div>
#container {
height: 100px;
background: grey;
}
#list {
max-height: 70px;
overflow: auto;
background: #ddf;
}
#content {
min-height: 30px;
height: auto;
background: #fdf;
}
// For testing
setInterval(function(){
$('ul').append('<li>Test</li>');
},3000);
http://jsfiddle.net/V8yuN/
如果你希望 DIV#content
一开始占据整个高度,但随着 DIV#list UL
的增长而缩小,那么你想要通过 DIV#content
实现什么目的?请注意,我将 UL
放在了一个 DIV
中。
上面的示例演示了你所描述的方式(DIV#content
被推到底部)。我的问题是,你的设计中 DIV#content
的高度有什么影响吗?
编辑
请注意,如果你将 #container
设为 overflow: hidden
并将 #content
的 height
设为 100%
,它会看起来像是 #container
正在缩小。
#container {
height: 100px;
background: grey;
overflow: hidden;
}
#list {
max-height: 70px;
overflow: auto;
background: #ddf;
}
#content {
height: 100%;
background: #fdf;
}
http://jsfiddle.net/V8yuN/2
我不确定这是否会导致你的设计出现问题,如果实际内容需要显示(例如,如果它是动态更改的)。
编辑2
以下代码可以实现所有功能,但无法实现#content
文本的vertical-align
:
HTML
<div id="container">
<div id="push">
<div id="list">
<ul></ul>
</div>
<div id="content">
<div class="border-top"></div>
<div id="content-inner">
<span>TEST CONTENT</span>
</div>
</div>
</div>
<div class="border-bottom"></div>
</div>
CSS
#container {
height: 100px;
background: grey;
}
#push {
height: 95px;
overflow: hidden;
}
#list {
max-height: 70px;
overflow: auto;
background: #ddf;
}
#content-inner {
min-height: 100px;
background: #dfd;
margin: 0;
border-left: 5px solid #fdf;
border-right: 5px solid #fdf;
}
.border-top {
background: #fdf;
border-radius: 5px 5px 0 0;
height: 5px;
}
.border-bottom {
background: #fdf;
border-radius: 0 0 5px 5px;
height: 5px;
}
http://jsfiddle.net/V8yuN/6/