我需要将宽度为980像素
,高度为500像素
(class="main")的网站主体只在鼠标悬停在一个滚动div上时固定,并且该滚动div具有1500像素的高度
和100%的宽度
(class="container-scroll"),该滚动div位于具有500像素高度的
其他div内(class="container")。
感到很困惑,对吗?
我已经创建了一个示例,我已经接近目标,问题是如果我将主体设置为固定,它将随着页面一起滚动,而不仅仅是在div内部滚动。
这是我的示例:https://jsfiddle.net/8oj0sge4/1/embedded/result/
HTML:
<div id="wrapper">
<div class="container">
<div class="container-scroll">
<div class="main">
</div>
</div>
</div>
</div>
CSS:
#wrapper {
width: 100%;
height: 1500px;
border: 1px solid red;
padding-top: 380px;
}
#wrapper .container {
border: 1px solid green;
width: 100%;
height: 500px;
overflow: scroll;
}
#wrapper .container-scroll {
height: 1500px;
width: 100%;
border: 1px solid yellow;
}
#wrapper .main {
width: 980px;
height: 500px;
background: black;
overflow: scroll;
/*position: fixed;*/
}