2012-02-07 120 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