Navbar仅在Safari上拉伸到全高

问题描述 投票:0回答:2

我有一个在所有浏览器中看起来都很棒的导航栏,除了在Safari上 - 它在全屏高度(但不是宽度)拉伸。在所有浏览器中它看起来像这样:qazxsw poi

https://imgur.com/KB1sBlM和Safari ...好吧:enter image description here

https://imgur.com/g1L6wxe

我的第一个假设和怀疑是enter image description hereposition:stickylinear-gradient,但这只是我的怀疑。甚至不确定它是否是一个CSS问题。我在那里也使用react-scroller,所以我的问题是什么?

这是我的SCSS代码:

Navbar将军:

box-shadow

商标:

.thematic-area-nav {
  position: sticky;
  position: -webkit-sticky;
  width: 70vw;
  top: 0;
  left: 0;
  z-index: 2;
  font-size: 1.3vw;
  -webkit-box-shadow: 0 0 25px 1px #000000;
  box-shadow: 0 0 25px 1px #000000;
  border-radius: 0 0 5px 5px;
  background: -webkit-gradient(
    linear,
    left top,
    left bottom,
    from($color-background-primary),
    color-stop(50%, rgb(237, 237, 237)),
    to($color-background-primary)
  );
  background: -webkit-linear-gradient(
    top,
    $color-background-primary 0%,
    rgb(237, 237, 237) 50%,
    $color-background-primary 100%
  );
  background: -o-linear-gradient(
    top,
    $color-background-primary 0%,
    rgb(237, 237, 237) 50%,
    $color-background-primary 100%
  );
  background: linear-gradient(
    to bottom,
    $color-background-primary 0%,
    rgb(237, 237, 237) 50%,
    $color-background-primary 100%
  );
  color: black;
  padding: 10px;

  & > * {
    color: black;
  }

  & > ul {
    list-style: none;
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 25% auto;
    grid-template-columns: 25% auto;
  }
}

纽扣:

.thematic-area-nav__logo {
  -ms-grid-column: 1;
  -ms-grid-column-span: 1;
  grid-column: 1/2;
  -ms-flex-item-align: center;
  -ms-grid-row-align: center;
  align-self: center;
  width: 100%;
  height: 150%;
}

这确实是一个CSS问题吗?

css safari
2个回答
1
投票

我查看了来自jsbin的html / scss代码,进行了一些清理并设法实现了我认为接近你想到的东西。

一些说明:

除非有充分的理由不这样做,否则请避免使用vw和vh作为字体大小。

如果以%为单位指定宽度/高度,请始终弄清楚浏览器如何计算这些(请问自己“什么的百分比?”)。

使用.thematic-area-nav__areas { -ms-grid-column: 2; -ms-grid-column-span: 1; grid-column: 2/3; display: -ms-grid; display: grid; grid-template-columns: repeat(auto-fit, minmax(12vw, 16vw)); grid-gap: 0.5em; & > button { border-top: none; border-bottom: none; border-right: 1px solid rgb(218, 218, 218); border-left: 1px solid rgb(218, 218, 218); border-radius: 5px; -webkit-box-shadow: 1px 1px 1px; box-shadow: 1px 1px 1px; background-color: $color-background-primary; font-size: 1vw; &:hover { color: black; -webkit-box-shadow: inset 1px 1px 1px; box-shadow: inset 1px 1px 1px; font-weight: bold; } &:focus { outline: none; -webkit-box-shadow: inset 1px 1px 1px; box-shadow: inset 1px 1px 1px; font-weight: bold; } } } .thematic-area-nav__singleThematicArea { & a { text-decoration: none; color: black; } & > * { text-decoration: none; cursor: pointer; color: black; } } - 它有帮助。

避免混合camelCase和-his__thingy。

保持代码整洁。

HTML

https://validator.w3.org/

SCSS

<div class="thematic-area-nav">
  <div class="thematic-area-nav__logo-wrapper">
    <img class="thematic-area-nav__logo" src="https://picsum.photos/200/90" alt="Logo Coaching People">
  </div>
  <ul class="thematic-area-nav__areas">
    <li class="thematic-area-nav__singleThematicArea"><a class="Obszar tematyczny 1">Obszar tematyczny 1</a></li>
    <li class="thematic-area-nav__singleThematicArea"><a class="Obszar tematyczny 2">Obszar tematyczny 2</a></li>
    <li class="thematic-area-nav__singleThematicArea"><a class="Obszar tematyczny 3">Obszar tematyczny 3</a></li>
    <li class="thematic-area-nav__singleThematicArea"><a class="Obszar tematyczny 4">Obszar tematyczny 4</a></li>
  </ul>

</div>

1
投票

反应代码不太可能导致问题。你能复制你的react应用程序创建的html,css代码并创建一个只有那些的测试用例吗?当你的JS没有“启用”时,确定是否出现问题会很好。您如何分享指向您的回购的链接?

一些旁注:在按钮内放一个链接似乎不对。它肯定会失败任何可访问性评估,同样class =“Obszar tematyczny 3”值似乎不正确,ul元素应该只有li作为子项,在其中放置其他任何东西,好吧,错误。

你的风格中也有很多弹性盒怪。通过阅读它我真的无法理解你的意图。我认为您并不完全熟悉属于flex容器的flexbox属性以及属于其子容器的属性。

除此之外,您可以停止使用*选择器。停下来。如果你这样做,世界将是一个更好的地方。

© www.soinside.com 2019 - 2024. All rights reserved.