html - 创建一个覆盖整个屏幕的黑色半透明div
问题描述
我想创建一个像下面这样的半透明背景,而不是白色的 div,只有半透明的背景。试过但它不起作用。这是我尝试过的。
.container---popup {
background: rgba(0, 0, 0, 0.5);
border: 0px none transparent;
overflow: hidden;
margin: 0px;
padding: 0px;
-webkit-tap-highlight-color: transparent;
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
transition: opacity 0.3s ease 0s;
visibility: visible;
border: none !important;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
-o-user-select: none;
z-index: 2147483647;
}
<section class="container---popup">
</section>
解决方案
.popup-background {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 5000;
}
z-index
你的白色弹出窗口应该大于z-index
of .popup-background
。
推荐阅读
- redirect - 如何在 Google Cloud 中将 www 重定向到非 www?
- python - Python:日期时差给出不正确的结果
- dji-sdk - DJI Mobile SDK - 如何计算相邻航点之间的距离?
- php - 如何将扩展 WC_Product_Variable 的自定义 WooCommerce 产品类型添加到购物车
- java - 在类中如何从实例中获取属性?
- vue.js - 移除 style="display:none;" 时的 CSS 高度过渡
- javascript - 老虎机显示零作为结果
- html - 我正在尝试修改此 CSS 代码。每当我点击它时,我将如何防止它缩小
- visual-studio-2013 - 想要获取 2003 年至今的值
- ubuntu - Ubuntu16.04 Gnome 无法保存设置