简体   繁体   English

子容器的框影叠加滚动条

[英]Box-shadow overlaying scrollbar of child container

So I'm working on a page where the desired behavior on mobile is to have all links displayed horizontally in the nav, and be hidden via overflow if they're collectively too wide. 因此,我正在开发一个页面,在该页面上,移动设备上所需的行为是使所有链接在导航栏中水平显示,并且如果它们在一起的宽度太大,则通过溢出将其隐藏。 To indicate to the user that there's additional items on scoll, I've added a white box-shadow with opacity that will slightly obscure the links that are being covered. 为了向用户指示scoll上还有其他项目,我添加了带有不透明性的白色方框阴影,该阴影会稍微掩盖所覆盖的链接。 Currently, this shadow is added to an adjacent container with the BUY NOW button. 当前,此阴影已通过“立即购买”按钮添加到了相邻的容器中。

Here is a codepen showing the current behavior: 这是显示当前行为的codepen:

http://codepen.io/thecox/pen/wWWrej?editors=1100 http://codepen.io/thecox/pen/wWWrej?editors=1100

LESS

.sticky-nav-menu {
  display: -webkit-flex;
  display: flex;
  align-items: center;
  width: auto;
  height: 100%;
  margin: 0;

  li {
    display: inline-block;
    white-space: nowrap;
    padding-right: 25px;
    margin-right: 0;

    &.active a {
      color: fade(@jet-dark, 80);
    }

    &:last-of-type {
      margin-right: 0;
    }
  }
}

.sticky-nav-overflow {
  height: 100%;
  margin-right: 4%;
  overflow: scroll;
}

.sticky-nav-mobile {
  padding-left: 2%;
  z-index: 1;
  box-shadow: -10px 0 5px 13px rgba(255, 255, 255, 1);
}

HTML 的HTML

<nav class="sticky-nav js-sticky-nav clearfix">
  <div class="sticky-nav-inner">
    <div class="sticky-nav-overflow">
      <ul class="sticky-nav-menu">
        <li class="active">
          <a href="#lorem" class="sticky-nav-link">THE LOREM</a>
        </li>
        <li>
          <a href="#lorem" class="sticky-nav-link">THE IPSUM</a>
        </li>
        <li>
          <a href="#lorem" class="sticky-nav-link">THE CAESAR SALAD</a>
        </li>
        <li>
          <a href="#lorem" class="sticky-nav-link">THE RIO GRANDE</a>
        </li>
      </ul>
    </div>
    <div class="sticky-nav-mobile">
      <a href="#" class="sticky-nav-cta">BUY NOW</a>
    </div>
  </div>
</nav>

Shrink the screen to 400px or below (I'm seeing this behavior mostly on Firefox, resized with devtools) and you'll see that when the link container is scrolled to the far right, the scrollbar is covered up by the box-shadow in an unattractive manner. 将屏幕缩小到400px或以下(我主要在Firefox上看到这种现象,使用devtools调整了大小),您会看到当链接容器滚动到最右边时,滚动条被一种没有吸引力的方式。 I'm wondering if anyone has any thoughts how this could be resolved with the current structure. 我想知道是否有人对如何使用当前结构解决此问题有任何想法。 Or any other method that might yield better results. 或其他可能产生更好结果的方法。

Any and all answers are appreciated. 任何和所有的答案表示赞赏。 Thanks for your assistance! 谢谢你的协助!

If i understood correctly the problem is box shadow covering scroll on screens bellow 400px. 如果我正确理解问题是框阴影覆盖在400像素以下的屏幕上滚动。 You can avoid this by changing margin right value on screens from 4% to 8% for example. 您可以通过将屏幕上的边距权利值从4%更改为8%来避免这种情况。

.sticky-nav-overflow { margin-right: 8%;}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM