javascript - 可滚动覆盖,下方有固定内容

标签 javascript html css

我需要让这个例子中的叠加层能够一直滚动到屏幕之外。内容需要位于固定位置,如下例所示。我怎样才能让覆盖 div 一直滚动到视口(viewport)之外?

示例站点: https://www.ssk.com/

HTML

<div class="test-overlay"></div>
    <div class="test-content-container"></div>

CSS

.test-overlay {
    background: orange;
    position: relative;
    width: 100%;
    height: 100vh;
    text-align: center;
    z-index: 995;
}

.test-content-container {
    background: rgba(156,64,81,1.00);
    position: fixed;
    top: 0px;
    left: 0px;
    font-size: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    min-width: 100%;
}

最佳答案

我通过在包含这两个元素的容器 div 底部添加 100% 填充来解决这个问题。

HTML

<div class="test-complete-container">
<div class="test-overlay"></div>
    <div class="test-content-container"></div>
</div>

CSS

.test-overlay {
    background: orange;
    position: relative;
    width: 100%;
    height: 100vh;
    text-align: center;
    z-index: 995;
}

.test-content-container {
    background: rgba(156,64,81,1.00);
    position: fixed;
    top: 0px;
    left: 0px;
    font-size: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    min-width: 100%;
}
    .test-complete-container {
        height: 100%;
        width: 100%;
        padding-bottom: 100%;
    }

关于javascript - 可滚动覆盖,下方有固定内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54270759/

相关文章:

使用 Array.includes() 和测试重复项目的 JavaScript 问题

javascript - 显示尺寸太小时内容重叠

php - HTML 表格在带有服务器数据的表格中自动换行

css - 网页水平滚动【页面宽度问题】

javascript - 如何在自动完成 jquery 中提交有关选择项目的表单?

javascript - 当窗口进入移动 View 时,.htaccess 文件规则会扰乱菜单栏布局

html - 使用纯 HTML 切换到移动 View

html - 导航菜单的第一项有奇怪的高度

css - 如何在正文背景图片上设置div

javascript - 使用mozilla PDFJS如何显示所有页面而不是单个页面