css - 添加叠加层以覆盖网页的全部内容

标签 css

我想知道是否有一种方法可以创建一个黑色透明覆盖层来基本上覆盖网页的全部内容?

<body>
  <div class="main-container">
    <!--many more divs here to create webpage-->
  </div>
</body>

最佳答案

在 div 上使用此 css 来创建黑色透明覆盖层:

#overlay {
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    position: fixed;
    top:0;
    left: 0;
}

关于css - 添加叠加层以覆盖网页的全部内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14320215/

相关文章:

html - 将 div 水平和垂直居中对齐后

css - 对齐图像 - 水平

html - 此图像不会在其 Bootstrap 列中居中

css - 如何将样式应用于 PrimeFaces 数据表?

html - 如何防止 float 元素影响 "text-align: center"文本?

CSS如何让div永远在最前面

jquery - < IE 9 的背景大小和位置替代方案

css - 显示属性值为 inline(only) 的元素中的居中对齐文本

NetBeans 7.1 中的 JavaFX 2.1 CSS 样式警告

html - CSS 圆 Angular 元素在 IE11 中失败