2012-02-07 121 views
1

the main source of the problem, innder div 100% outside or perent div内蒙古度100%的高度股利

这显然发生的原因是因为上面的灰箱。现在我已经尝试使用97%,但在调整大小时效果不佳。由于外部div可以改变,我不能使用静态值。

有什么办法可以解决这个问题吗?没有JavaScript。如果不能用CSS然后什么高度:expresion(???);为了它 ?

下面的代码我到目前为止的方式:

.outside_div { 
    width:227px; 
    height:500px; 
} 

.scrolabe_div { 
    width:100%; 
    height:100%; 
    overflow:auto; 
} 

预先感谢您。

回答

2

可以使用bottom属性来代替。

.outside_div { 
    position: absolute; 
    width: 227px; 
    height: 500px; 
} 

.scrolabe_div { 
    position: absolute; 
    width: 100%; 
    top: 50px; /* since the top doesn't change, fix it here */ 
    bottom: 10px; /* set this accordingly, probably 10px */ 
    overflow: auto; 
} 
+0

您先生是我的新英雄,谢谢。请投这个GUY – Kivylius 2012-02-08 00:13:38

+0

哈哈哈,欢迎您:) – caleb 2012-02-08 00:15:45

2

从滚动DIV删除高度:

.scrolabe_div { 
    width:100%; 
    overflow:auto; 
} 

当你指定基于heightwidth百分比计算的值是相对于父容器。如果去除.scrollable_div高度定义,然后它会在height成长与相对于其内容。

+0

号,以防止一起滚动。 – Kivylius 2012-02-07 23:58:36

0

只是删除从你的CSS或样式的height。浏览器呈现的内元件的高度决定外一个的长度,从而指定高度是不必要

+0

防止全部滚动, – Kivylius 2012-02-08 00:03:18