css - 在叠加层顶部放置一个按钮
问题描述
我有一个这样的搜索屏幕
. 单击搜索时,我正在显示带有叠加层的繁忙图像。但是屏幕上有一个停止按钮,我无法单击它,因为它位于覆盖下方。你能帮忙解决这个问题吗?
<input type="button" value="Stop" style="z-index: 100;position: absolute;" />
#overlay {
position: fixed;
display: none;
width: 100%;
height: 97.5%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 2;
height:97.5%%;
margin-top: .4%;
}
解决方案
如果您单独测试它,它可以工作。但我认为问题在于您的停止按钮是具有相对位置的元素的子元素。也许您必须使整个侧边栏菜单成为绝对或不被覆盖覆盖。尝试将停止按钮与加载程序图像放在同一级别,这样会更全面。
#overlay {
position: fixed;
display: block;
width: 100%;
height: 97.5%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 2;
height:97.5%%;
margin-top: .4%;
}
<div id="overlay"></div>
<input type="button" value="Stop" style="z-index: 100;position: absolute;" />
推荐阅读
- c - 如何检查 gdb 中的 [sp,#4] 值
- http - 对于未请求的必需数据,合适的 HTTP 错误是什么
- python - 减少 PyQt5 中的间距 - GridLayout - 小部件之间
- python - 如何在 Python 中使用 plt.imshow(data) 保存图像之前打印出 16 位数据?
- ios - 使用带有 Fastlane 的 plist 变量增加内部版本号
- regex - XSLT 2 分析字符串查找块名称
- python - 使用 Tkinter 中的菜单栏在页面之间切换
- kotlin - 如何有选择地使用 Kotlin DSL 应用一些插件以及 gradle 和 android 的插件块
- python - 在python中创建输出文件名+文件路径的目录文档
- python - Python 3 - 序列化生成的 numpy 数组