html - 网站页脚不会被模态弹出表单覆盖
问题描述
我的网站有一个模态弹出表单,其背景应该覆盖整个视口。该网站包含页眉和页脚,模式由简单的 javascript 触发。一切正常,除了我的页脚仍然显示在顶部并且没有覆盖模式背景。
这是我的CSS代码:
#footer {
position:fixed;
width: 100%;
z-index: 2;
bottom: 0;
padding: 8px;
background-color: #688596;
color: white;
box-shadow: 0px 2px 8px #676767;
}
.modalBackground {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(180, 180, 180, 0.6);
}
javascript 将 display:none 设置为 display:block 用于 .modalBackground。正如我所说,一切正常,但页脚仍然位于顶部。我在这里想念什么?提前致谢!
解决方案
这是因为z-index
of footer
大于z-index
你的modal
。
具有较大堆栈顺序的元素始终位于具有较低堆栈顺序的元素之前。
阅读更多关于z-index
这里。试试这个(我刚换了z-index
es):
#footer {
position:fixed;
width: 100%;
z-index: 1;
bottom: 0;
padding: 8px;
background-color: #688596;
color: white;
box-shadow: 0px 2px 8px #676767;
}
.modalBackground {
display: none;
position: fixed;
z-index: 2;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(180, 180, 180, 0.6);
}
推荐阅读
- python - Pandas:根据另一列的键在现有列上映射字典值以替换 NaN
- python - 在 virtualenv pip 全局安装和 pip3 本地安装
- extjs - 我是否必须在现代和经典工具包的 ExtJS 通用应用程序中复制视图?
- python-3.x - 如何在两个相同的csv文件之间仅获取pandas中的匹配列值
- android - Wordpress 电子商务网站和 Android Studio 应用程序集成
- vue.js - 在vuex状态下保存用户认证状态是安全的解决办法?
- flutter - 如何在 Flutter 运行时向 Row 对象添加项目?
- odata - 如何区分对 SAP 的调用是来自 OData API 还是来自 Fiori 应用程序
- scala - 火花红移下推过滤器
- magento - Magento 移动应用 (Flutter) 使用网站结账