2011-11-02 121 views
0

我有一個固定位置的DIV,其內容使用jQuery添加。固定位置動態高度的Div

當其高度變得大於屏幕尺寸時,我無法看到DIV底部的內容。

要看下面我需要使用瀏覽器的縮放工具。

如果div的高度超過特定限制,它可能會滾動。

任何幫助表示讚賞。

+1

例將是很好。 (http://www.jsfiddle.net) – Joonas

回答

5

您可以在div上設置max-height CSS屬性,它會增加到不大於您指定的值。然後設置overflow: auto以使內容在可見區域外時可滾動。

0

使用CSS來獲得滾動功能: overflow: scroll

0

指定一個類的div

試試這個..

.className 
    { 
     height:100px; \* default hight of the div*\ 
     overflow: auto;  
    } 
0

嘗試類似:

設置height: auto;如果你想有最低高度x,那麼你可以寫

height:auto; 
min-height:30px; 
height:auto !important;   
height:30px; 
0

只設置最大高度爲DIV問題的

*html yourdiv { 
    height: expression(this.scrollHeight > 332 ? "333px" : "auto"); /* sets max-height for IE */ 
    overflow:auto; 
} 
yourdiv{ 
    max-height: 333px; /* sets max-height value for all standards-compliant browsers */ 
    overflow:auto; 
}