css - Android浏览器的位置: fixed and z-index issue

标签 css css-position z-index android-browser

为了更好地说明,让我举个例子:

jsFiddle: http://jsfiddle.net/yhurak3e/

或者您可以在这里阅读:

#box1 {
  width: 100%;
  height: 40px;
  position: fixed;
  top: 0;
  left: 0;
  background: green;
  z-index: 5;
}

#box2 {
  height: 300px;
  position: relative;
  background: yellow;
}

#box3 {
  height: 100%;
  width: 100%;
  left: 0;
  top: 0;
  position: fixed;
  background: black;
  opacity: .8;
  z-index: 10;
}

#box4 {
  left: 20px;
  top: 20px;
  right: 20px;
  bottom: 20px;
  position: fixed;
  background: blue;
  z-index: 11;
}
<div id="box1">box1</div>
<div id="box2">box2
  <div>
    <div id="box4">box4</div>
  </div>
</div>
<div id="box3">box3</div>

在所有其他浏览器中,#box4(蓝色的)出现在其他元素的顶部,除非我为它的祖先之一提供 z-index 属性。这是预期的结果。

在 Android 的默认浏览器(在 4.1 上测试)中,#box4 位于#box1 和#box3 之下。

有人知道解决它的 CSS 解决方法吗?

谢谢!

最佳答案

来自 this 的类似问题的解决方法线程是应用

-webkit-transform:translateZ(0);

#box4

关于css - Android浏览器的位置: fixed and z-index issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26408978/

相关文章:

javascript - 如何永久自动滚动到div的底部?

css - 修复了 IE11 中的位置错误行为

html - 需要帮助水平居中绝对定位的 DIV

css - 删除 IE 中的 z-index 属性

Jquery:如何将图像叠加在一起?

CSS3动画-变换: scaleX(-1) - go/back - size down - why?

html - 绝对定位的标题不喜欢在 Chrome 中被推送

html - 悬停时菜单如何保持静止?

ios5 - iOS 5 固定定位和虚拟键盘

css - z-index 在 IE8 中不工作。为什么?