html - Chrome/Safari 和 Firefox 中的 z-index 问题(嵌套元素)

标签 html css ipad browser z-index

基本上 .second 必须高于 .third。不过,这仅在 Firefox 中。不幸的是,我无法将 .second.fifth 中移出,这就是为什么它给我带来如此困难的原因。

更多信息:.third 应该是模态背景,使内容 .fifth 和页脚 .fourth 变暗。模态内容是 .second。该网络应用程序应该适用于 iPad 上的 Safari。

JSFiddle

<div class="first"></div>
<div class="fifth">
    <div class="second">I should be on top.</div>
</div>
<div class="third"></div>
<div class="fourth"></div>

.first{
    z-index: 10;
    /* styling */
    position: fixed; top: 0; left: 0; right: 0; height: 50px; background: lightblue;
}
.second{
    z-index: 9;
    /* styling */
    position: fixed; top: 100px; left: 50px; right: 50px; bottom: 100px; background: darkseagreen;
}
.third{
    z-index: 8;
    /* styling */
    position: fixed; top: 50px; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.1);
}
.fourth{
    z-index: 7;
    /* styling */
    position: fixed; bottom: 0; left: 0; right: 0; height: 50px; background: indianred;
}
.fifth{
    /* styling */
    position: fixed; top: 50px; left: 0; right: 0; bottom: 50px; background: darkgrey;
}

最佳答案

.fifth 一个大于 .thirdz-index

    .first{
        z-index: 10;
        /* styling */
        position: fixed; top: 0; left: 0; right: 0; height: 50px; background: lightblue;
    }
    .second{
        z-index: 9; /* You probably do not need this */
        /* styling */
        position: fixed; top: 100px; left: 50px; right: 50px; bottom: 100px; background: darkseagreen;
    }
    .third{
        z-index: 8;
        /* styling */
        position: fixed; top: 50px; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.1);
    }
    .fourth{
        z-index: 7;
        /* styling */
        position: fixed; bottom: 0; left: 0; right: 0; height: 50px; background: indianred;
    }
    .fifth{
        z-index: 9;
        /* styling */
        position: fixed; top: 50px; left: 0; right: 0; bottom: 50px; background: darkgrey;
    }
    <div class="first"></div>
    <div class="fifth">
        <div class="second">I should be on top.</div>
    </div>
    <div class="third"></div>
    <div class="fourth"></div>

关于html - Chrome/Safari 和 Firefox 中的 z-index 问题(嵌套元素),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31945648/

相关文章:

html - 试图在类别下的页面上显示标题

Javascript em resize based on window/viewport dimension not affect in-doc style text/css?

html - 我要执行的操作的 CSS 选择器是什么?

ios - 允许在 Apple Silicon Mac 的 "Designed for iPad"应用程序上调整大小

html - 阻止来自 html 的内联 css 并使用来自外部 css 的渐变背景

css - 如何为导航栏关闭 Materialize 的默认阴影

jquery - Bootstrap Accordion 嵌套网格

html - CSS Float-right *有时* 导致元素出现在父 div 之外

iphone - 在 iOS 上,如何用轮廓填充路径? (或同时填充和描边路径)

ios - iPad 模型 UIViewController 位置