2011-09-15 91 views
0

我有一個div需要填寫瀏覽器視口的高度,但仍然表示當用戶上下滾動網頁時位於同一位置。位置:固定;這樣做,但我無法使用它,因爲它使得div的生澀和緩慢的溢出滾動條。有,我可以用這樣的例子,我現在有一個位置或方法:IE7分隔位置固定

div.panel { 
    position: absolute; 
    top: 36px; 
    right: 0; 
    overflow: auto; 
    background: #636362; 
    padding: 0 0 20px 0px; 
    width: 290px; 
    height: 100%; 
} 

回答

1

我不知道你是什麼意思與「幹慢」,因爲所有的滾動條動作相同。這是我會怎樣解決您的問題:

HTML:

<div class="fixed">I'm fixed!</div> 
<p>Rest of page</p> 

CSS:

html, body { 
    /* make sure the page is at least height of viewport */ 
    height: 100%; 
} 
body { 
    /* because the fixed div is no part of the flow, 
    make sure it is not overlapping the webpage */ 
    padding: 0 0 0 100px; 
} 
.fixed { 
    height: 100%; 
    width: 100px; 
    left: 0; 
    position: fixed; 
    background: #e0e0e0; 
    /* only vertical-scrolling, but can be changed of course */ 
    overflow-y: scroll; 
} 

JSfiddled Live example

作品至少在IE7,IE8和Firefox。

+0

謝謝你,我想我已經用你的代碼作爲出發點解決了這個問題。這與我使用的一些jQuery庫有關,它在IE中注入了額外的樣式。緩慢,我的意思是滾動條的響應延遲。 – melon

+0

延遲問題是否以這種方式解決?我從來沒有真正體驗過一個慢滾動條,只有當我的Windows進程瘋狂並且我的光標達到1以下的fps時才行。 –