1

我有这样的布局:

+---------------------------------+
| #container                      |
|+-------------------------------+|
|| #top                          ||
|| This changes height           ||
||                  dynamically  ||
|+-------------------------------+|
|+-------------------------------+|
|| #mid                          ||
||                               ||
|| This changes height           ||
||                 dynamically   ||
|+-------------------------------+|
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |
|+-------------------------------+|
|| #bot                          ||
||       This has fixed height   ||
||                               ||
|+-------------------------------+|
+---------------------------------+

topmid被放大时,它们会从容器中溢出。我怎样才能做到,这样他们就不会越过bot?当他们想要溢出时,内部 div 应该会出现一个滚动条(又名溢出自动)

CSS

#container{
    position: absolute;
} //Container's container has position:relative.
#bot{
    position: absolute;
    bottom: 0px;
}
4

2 回答 2

4

创建一个#parentdiv 并将其设置max-heightscreen height - #bot height, 设置overflowscroll.

HTML:

+---------------------------------+
| #container                      |
|+-------------------------------+|
|| #parent                       ||
||+-----------------------------+||
||| #top                        |||
||| This changes height         |||
|||                  dynamically|||
||+-----------------------------+||
||+-----------------------------+||
||| #mid                        |||
|||                             |||
||| This changes height         |||
|||                 dynamically |||
||+-----------------------------+||
|+-------------------------------+|
|                                 |
|                                 |
|                                 |
|                                 |
|                                 |
|+-------------------------------+|
|| #bot                          ||
||       This has fixed height   ||
||                               ||
|+-------------------------------+|
+---------------------------------+
于 2013-11-12T14:42:49.740 回答
0

尝试将heightwidth设置为他们俩的设定量。此外,overflow:应设置为scroll

于 2013-11-12T14:37:33.397 回答