如何使用固定的滚动div来滚动窗口的其余部分?

时间:2014-10-22 15:52:42

标签: javascript jquery html css

这是jfiddle http://jsfiddle.net/pq5ckkcg/4/。无论鼠标在哪里,我基本上都需要整个窗口和div一起滚动。我该如何做到这一点?

<div id="bottomwrap">
<div id="element"></div>
<div id="element"></div>
<div id="element"></div>
</div>

#bottomwrap {
position:fixed;
top:45px;
right:0;
width:80%;
overflow-y:scroll;
bottom:0;
background-color:#666;
}
#element {
float:left;
width:200px;
height:300px;
background-color:#000;
margin:20px;
}

1 个答案:

答案 0 :(得分:0)

您的父div需要相对定位:

#bottomwrap {
    position:relative;
    margin-top:45px;
    float: right;
    width:80%;
    overflow-y:scroll;
    bottom:0;
    background-color:#666;
}

http://jsfiddle.net/pq5ckkcg/3/