javascript - div 完全覆盖页面

标签 javascript jquery html css

我有一个 div,我想完全覆盖一个页面。我不希望页面上显示任何内容。 div 应该覆盖在页面上并隐藏页面上的所有内容。为了创建这样的叠加层,我使用了以下 CSS:

.overlay {
   position: absolute;
   width: 100%;
   height: 100%;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   z-index: 1000;
}

但是如果覆盖的页面太长,页面的某些部分仍然显示。我怎样才能使 div 完全覆盖页面?将位置设置为固定无济于事,因为叠加层有多页长,滚动条会被破坏。

最佳答案

您要用于覆盖 div 的 CSS 是这样的。

.overlay {
    position: fixed;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index:1001;
}

这应该用黑色 div 完全覆盖页面。

关于javascript - div 完全覆盖页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35735971/

相关文章:

jquery - 模式对话框不关闭 Bootstrap

html - Wordpress 改变 active 和 hover li 的颜色背景

javascript - 使用 clear 函数重新启用 radio 输入

javascript - jQuery 行验证

javascript - ServiceNow:从数组动态创建表

javascript - 使用 AJAX 隐藏子级的 div

jquery更改子尺寸以在调整大小后匹配父尺寸

javascript - 在 Javascript 中提取月份和日期

javascript - jQuery:价格不会更新 - 它不会正确减去(使用 switch 语句)

html - 我的响应式网站只能在某些设备上正常运行