html - 显示 : flex from display: none in breakpoint not working in safari on OSX

标签 html css safari flexbox

给定以下 HTML 和 CSS,myLinks div 在 1025 像素以下的屏幕上隐藏,并在 1025 像素以上的屏幕上显示为 flexbox。该 div 在 Safari 中保持隐藏状态。

#myLinks {
  display: none;
}

.menu-link {
    padding-top: 0.5em;
}

@media only screen and (min-width: 1025px) {
  #myLinks {
    background-color: transparent;
    display: -webkit-flex;
    display: flex;
    flex-direction: column;
    position: fixed;
    width: 300px;
    top: 10%;
    right: 0;
    height: 85vh;
    max-height: 85%;
    border-radius: 10px;
  }
}
<div id="myLinks" class="menu-link"></div>

真正奇怪的是我只是注意到页面上有元素,但没有被渲染。我可以点击它们,但我看不到它们。将 z-index 更改为 999 无法解决问题

编辑:这是一个完全构建的示例,我认为没有任何子项导致 #myLinks 被隐藏,因为从 #myLinks 中删除的 .menu-card 元素显示并正常工作,但也许这里的某些内容没有玩好 myLinks 中的某些东西...

全页运行

#myLinks {
  display: none;
}

.menu-link { 
    padding-top: 0.5em;
}

.menu-card {
    display: block;
    text-align: center;
    padding-bottom: 0;
    margin-left: 5%;
    margin-right: 5%;
    margin-bottom: 4%;
}

.card-text {
    text-align: center;
    font-size: 0.75em;
    padding: 0;
    margin: 0;
    line-height: 1;
}

/*Style navigation menu images*/
.menu-icon {
    display: block;
    max-width: 15%;
    vertical-align: middle;
    margin: auto;
}

/* Style navigation menu links */
#myLinks a {
    display: block;
    color: white;
    font-size: 1.4rem;
    text-shadow: 2px 2px black;
    text-decoration: none;
    text-align: center;
    margin-top: 0;
    padding: 14px 16px;
    padding-top: 0;
}

@media only screen and (min-width: 1025px) {
#myLinks {
        background-color: transparent;
        display: -webkit-flex;
        display: flex;
        flex-direction: column;
        position: fixed;
        width: 300px;
        top: 10%;
        right: 0;
        height: 85vh;
        max-height: 85%;
        border-radius: 10px;
    }

.menu-card a {
        position: relative;
        width: 100%;
    }

    .menu-icon {
        position: absolute;
        z-index: 1;
        right: 20%;
        max-height: 55%;
        border-radius: 50%;
        background-color: rgb(148, 181, 201);
        background-color: rgba(148, 181, 201, 0.9);
        transition: all 0.8s;
        max-width: 100%;
    }

    .card-text {
        display: -webkit-flex;
        display: flex;
        align-items: center;
        width: 0;
        top: 6%;
        height: 100%;
        max-height: 0;
        text-align: left;
        font-size: 125%;
        opacity: 0;
        color: #5DCA31;
        background-color: transparent;
        text-shadow: 2px 2px black;
        margin: 0;
        border-color: rgb(148, 181, 201);
        border-color: rgba(148, 181, 201, 0.9);
        border-style: solid;
        border-radius: 90px;
        transition: all 0.8s;
        padding-right: 0;
    }

    .menu-card:hover {
        background-color: transparent;
        opacity: 1;
        transition: all 0.8s;
    }

    .menu-card:hover .menu-icon {
        right: 5%;
    }

    .menu-card:hover .card-text {
        opacity: 1;
        padding-left: 10%;
        max-height: 65%;
        width: 100%;
        border-width: 8px;
        box-sizing: border-box;
        background-color: rgb(148, 181, 201);
        background-color: rgba(148, 181, 201, 0.9);
        padding-right: 100px;
        padding-top: 10px;
        padding-bottom: 10px;
        transition: background-color 0.8s, border-width 0.8s, max-width 0.8s;
    }
}
<div id="myLinks" class="menu-link">
  <div class="menu-card">
      <a href="#">
          <img class="menu-icon" src="https://nuclearterrortoday.org/img/home.jpg">
          <p class="card-text"  id="home">Home</p>
      </a>
  </div>
</div>

最佳答案

尝试使用

@media screen and (min-width: 1025px) {
    #myLinks {
        /* all the styles */
    }
}

或者只是

@media (min-width: 1025px) {
    #myLinks {
        /* all the styles */
    }
}

关键字“only”对旧的用户代理隐藏样式表。 希望这对您有所帮助!

关于html - 显示 : flex from display: none in breakpoint not working in safari on OSX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54679255/

相关文章:

html - 删除 Chrome 中的白线?

jquery 不会更改隐藏在 CSS 中的表单中的输入值

javascript - jquery 动画中的 child 的 child 保持不动

javascript - 我正在尝试进行验证但不在 JQuery 中工作

具有相同内容的 css 组元素

css - 边距/填充设置为 0 - 那么哪个单位为零?

css - 在 Safari 9.1.2 (11601.7.7) 中悬停时 SVG 过渡失败

css - 如何在 CSS 中设置 JavaFX SplitMenuButton 的样式

safari - 适用于 Web 设计师的 Windows 或 Linux 上的真实 Safari 模拟器

d3.js - 在某些情况下,SVG 在 Safari 中过滤模糊