javascript - 在固定元素上使用 fullpagejs 滚动

标签 javascript html css fullpage.js

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

这是我的 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>

关于javascript - 在固定元素上使用 fullpagejs 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29493782/

相关文章:

javascript - document.activeElement 的 jQuery 替代品

javascript - jQuery val() 用于字符串数组

javascript - HTML5/JS - 将 Canvas 导出为 PNG 时出错 - 来自其他服务器的图像

html - 我如何才能在我的网站中绝对定位包含带有 <object> 标签的 youtube 视频的 div?

html - 图像不会在 html 页面中溢出

css - 不改变网格大小的五列 Bootstrap 布局

javascript - 查找哪个链接导致路由更改

html - 底部对齐文本

javascript - 如何为 Material 卡标题指定固定宽度?

javascript - 将 jQuery 对象转换为 HTML