Javascript 如何获得固定的滚动div以与窗口的其余部分一起滚动?

Javascript 如何获得固定的滚动div以与窗口的其余部分一起滚动?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,这是小提琴。我基本上需要整个窗口和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

这是小提琴。我基本上需要整个窗口和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;
}

您的父div需要相对定位:

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

我无法得到需要的东西,你想让整个灰色容器滚动吗?你是在寻找像我更新了jfiddle这样的东西,但是我需要div和窗口的其余部分一起滚动,这样div就不会滚动到它上面的白色区域。我需要底部包裹div上面的白色区域保持在原来的位置,并且整个窗口都有背景图像,所以我不能在上面放一个div。