2011-09-15 88 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时才行。 –