使用fullpagejs在固定元素上滚动

Scrolling with fullpagejs over fixed elements

本文关键字:元素 滚动 fullpagejs 使用      更新时间:2023-09-26

我正在尝试用fullpage.js设计一个网站,该网站包含覆盖部分屏幕的固定元素。问题是,当鼠标在这些固定元素上时,滚动无法正常工作(参见jsfiddle示例)

这是我的html:

<div class="hider" style="top: 0"></div>
<div id="fullpage">
    <div class="section">Section 1</div>
    <div class="section">Section 2</div>
    <div class="section">Section 3</div>
</div>
<div class="hider" style="bottom: 0"></div>

这是我的css:

body {
    text-align: center;
}
.section {
    font-size: 32px;
    background-color: #b3d4fc;
}
.hider {
    width: 100%;
    height: calc(50% - 20px);
    background-color: #3461ff;
    position: fixed;
    z-index: 1;
}

我希望鼠标在固定元素上滚动,智能手机或平板电脑用手指在固定div上上上下滑动。我该怎么做?

只需将固定元素放在整页div中,它就可以工作了。

<div id="fullpage">
    <div class="hider" style="top: 0"></div>
    <div class="section">Section 1</div>
    <div class="section">Section 2</div>
    <div class="section">Section 3</div>
    <div class="hider" style="bottom: 0"></div>
</div>