css - 位置 :fixed not working in Chrome? 的子项的 z-index 是否有解决方法

标签 css google-chrome

Chrome 处理 position:fixed 元素下方的 z-index 的方式与 Firefox 或 Safari 不同。 -> jsfiddle

从 Adam Spiers 的另一个回答中,我了解到这是由于 on mobile WebKit and Chrome 22+, position: fixed always creates a new stacking context, even when z-index is auto .

有解决办法吗?有什么方法可以防止 chrome 创建新的堆叠上下文?替换 position: fixed 几乎不是一个选项,因为它用于修复使用 z-index 突出显示部分页面的网站教程软件。

最佳答案

如果你将粉色 div 的 z-index 设置为 0,像这样:

.div1 {
position: relative;
z-index: 0;
height: 100px;
background-color: pink;
}

并且你的绿色 div 的 z-index 为 1 它将在 chrome 和 firefox 中正确显示。

关于css - 位置 :fixed not working in Chrome? 的子项的 z-index 是否有解决方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25738825/

相关文章:

css - 如何用 3 个相同大小的 div 100% 填充一个 div 的所有空间?

html - 将父 div 保持为包裹子元素的宽度和高度

css - 如何更改突出显示/选定文本上的文本装饰的颜色

jquery - YouTube Embed 似乎干扰了 CSS 下拉菜单的悬停

javascript - Firebase 未加载到 Chrome 扩展内容脚本中

javascript - 在混合 android 应用程序中导航时在 chrome 设备中看到多个分离的 webview 实例

css - Twitter Bootstrap 帮助 block 的可折叠元素的正确控制样式是什么?

javascript - jQuery sticky header 在特定高度跳转

javascript - Chrome 使用 Lightbox 调用服务器两次

css - 相对元素与 Chrome 中的绝对元素重叠