Z-index无法在Safari中正确呈现-在所有其他浏览器中均可使用

时间:2019-05-21 23:50:40

标签: css webkit

我有一个导航菜单,一旦单击汉堡图标,它就会从屏幕的右侧滑入视图。它可以在Chrome和Firefox中正常运行-基本上在触发时需要50vw并垂直填充屏幕。但是,在Safari中,似乎z-index的行为不正确,因为菜单似乎被掩埋在页面其他元素的下面,最终根本看不到。

我尝试调整各种元素的z-index,看看这是否是简单的解决方法,事实证明它更复杂。我已经阅读了一些建议的论坛,其中包括“ -webkit-transform:translate3d(0,0,0);”。但不幸的是,这似乎也不起作用。如果您在Safari中检查sidebarMenu元素,您会发现它的位置正确,只是呈现不正确。

下面是指向代码笔的链接-我在此上缺少一些样式,因此定位并不是很正确,但是它有效地显示了我正在寻找的常规功能。在Safari中打开此链接时,您会看到sidebarMenu似乎根本没有呈现。 https://codepen.io/rmann20/pen/EzbeaV

示例代码:

<div class="header">
      <hr class="nav-rule">
      <div class="nav-container">
          <div class="nav-logo-container">
            <a href="index.html"><img class="nav-logo" src="images/nav_logo.png"></a>
            <input type="checkbox" class="openSidebarMenu" id="openSidebarMenu">
              <label for="openSidebarMenu" class="sidebarIconToggle">
                <div class="spinner diagonal part-1"></div>
                <div class="spinner horizontal"></div>
                <div class="spinner diagonal part-2"></div>
              </label>
              <div id="sidebarMenu">
                <ul class="sidebarMenuInner">
                  <li><a href="rooms.html">Rooms & Suites</a></li>
                  <li><a href="packages.html">Packages</a></li>
                  <li><a href="dining.html">Eat & Drink</a></li>
                  <li><a href="events.html">Meetings & Events</a></li>
                  <li><a href="weddings.html">Weddings</a></li>
                  <li><a href="experiences.html">Experiences</a></li>
                  <li><a href="neighborhood.html">Neighborhood</a></li>
                </ul>
                <ul class="sidebarMenuInnerSecondary">
                  <li><a href="about.html">ABOUT</a></li>
                  <li><a href="history.html">HISTORY</a></li>
                  <li><a href="gallery.html">GALLERY</a></li>
                  <li><a href="press.html">PRESS</a></li>
                  <li><a href="contact.html">CONTACT</a></li>
                  <li><a href="careers.html">CAREERS</a></li>
                </ul>
              </div>
          </div>
          <img class="nav-tagline" src="images/nav_tagline.png">
          <a class="nav-reservation-button" href="" target="_blank">RESERVE NOW</a>
      </div>
      <hr class="nav-rule">
    </div>




.header {
        display: flex!important;
        flex-wrap: wrap;
        margin: 0;
        padding: 10px 0 10px 0;
        width: 100%;
        max-width: 100%;
        box-shadow: none;
        background-color: #f5f4f0;
        position: fixed;
        height: 110px!important;
        overflow: hidden;
        z-index: 10;
        justify-content: space-between!important;
    }

    .nav-container {
        display: flex;
        height: 79px;
        width: 100%;
        align-items: center;
        justify-content: space-between;
    }

    .main {
        margin: 0 auto;
        display: block;
        height: 100%;
        margin-top: 60px;
    }
    .mainInner{
        display: table;
        height: 100%;
        width: 100%;
        text-align: center;
    }
    .mainInner div{
        display:table-cell;
        vertical-align: middle;
        font-size: 3em;
        font-weight: bold;
        letter-spacing: 1.25px;
    }
    #sidebarMenu {
        min-height: 100%;
        position: fixed;
        right: 0;
        width: 50vw;
        margin-top: 42px;
        transform: translateX(50vw);
        transition: transform 250ms ease-in-out;
        background-color: #f5f4f0;
        overflow: scroll;
        padding: 60px 60px 60px 60px;
        z-index: 10000!important;
    }
    .sidebarMenuInner{
        margin:8px;
        padding:0;
        border-top: 1px solid rgba(255, 255, 255, 0.10);
        list-style: none;
    }

    .sidebarMenuInner li a{
        color: #3d3936;
        font-family: 'QuincyCF-ExtraBold', Helvetica, Arial, Sans-Serif;
        font-weight: normal;
        font-style: normal;
        cursor: pointer;
        text-decoration: none;
        font-size: 3.2em;
    }

    .sidebarMenuInnerSecondary {
        margin-top: 60px;
        list-style: none;
    }
    .sidebarMenuInnerSecondary li {
        margin-top: 14px;
        margin-bottom: 14px;
    }


    input[type="checkbox"]:checked ~ #sidebarMenu {
        transform: translateX(0);
    }

    input[type=checkbox] {
        transition: all 0.3s;
        box-sizing: border-box;
        display: none;
    }
    .sidebarIconToggle {
        transition: all 0.3s;
        box-sizing: border-box;
        cursor: pointer;
        position: absolute;
        z-index: 99;
        height: 100%;
        width: 100%;
        top: 48px;
        right: 40px;
        height: 28px;
        width: 28px;
    }
    .spinner {
        transition: all 0.3s;
        box-sizing: border-box;
        position: absolute;
        height: 3px;
        width: 100%;
        background-color: #3d3936;
    }
    .horizontal {
        transition: all 0.3s;
        box-sizing: border-box;
        position: relative;
        float: left;
        margin-top: 3px;
    }
    .diagonal.part-1 {
        position: relative;
        transition: all 0.3s;
        box-sizing: border-box;
        float: left;
    }
    .diagonal.part-2 {
        transition: all 0.3s;
        box-sizing: border-box;
        position: relative;
        float: left;
        margin-top: 3px;
    }
    input[type=checkbox]:checked ~ .sidebarIconToggle > .horizontal {
        transition: all 0.3s;
        box-sizing: border-box;
        opacity: 0;
    }
    input[type=checkbox]:checked ~ .sidebarIconToggle > .diagonal.part-1 {
        transition: all 0.3s;
        box-sizing: border-box;
        transform: rotate(135deg);
        margin-top: 8px;
    }
    input[type=checkbox]:checked ~ .sidebarIconToggle > .diagonal.part-2 {
        transition: all 0.3s;
        box-sizing: border-box;
        transform: rotate(-135deg);
        margin-top: -9px;
    }

    .nav-logo-container {
      width: 260px;
      margin-left: 40px;
    }

我没有收到任何错误,其他所有内容似乎都正常运行,无法弄清为什么此时未显示。任何帮助将不胜感激!

0 个答案:

没有答案