0

我有一个用于每个页面的网站模板。我想让 2 个 div 自动调整内容的大小。

http://jsfiddle.net/agroe070/9QGjH/2/

如果蓝色 div 的内容大于 div,我希望 div 自动调整大小以适应内容,并且我希望绿色 div 也自动调整大小,因此绿色 div 的底部仍然与橙色 div 的底部。反之亦然。橙色 div 永远不会重新调整大小。

4

2 回答 2

0

使用 min-height 而不是 height 我认为它会解决你的问题

于 2012-05-05T18:07:04.097 回答
0

这些是我更改的 CSS 声明,它似乎可以按要求工作:

#wrapper{
    /* your other stuff */
    position: relative; /* to position the sidebar relative to this element */
}
#sidebar{
    position: absolute;
    top: 0;
    bottom: 50px;
    left: 10px;
    width: 190px;
    /* other stuff */
}

JS 小提琴演示

于 2012-05-05T17:11:25.833 回答