水平菜单,溢出效果淡入淡出

Daw*_*ski 5 css sass overflow css3

我正在使用CSS3/SASS,如果可能的话,我不想使用任何Javascript.我正在尝试制作一个水平菜单,其中overflow-x会在右侧产生漂亮的淡入淡出效果,因此移动设备上的用户会知道他可以左右移动它.

这是我想要完成的事情:

右侧文字很好淡出

...正如你在图片上看到的那样,右侧的文字正在逐渐消失,当然,这是一个OPTION3菜单项(因此它溢出).

到目前为止,我得到了菜单,但我真的不知道它们的溢出和技巧.

HTML:

<nav class="navbar">
  <ul class="navbar-list">
    <li class="navbar-item"><a href="#">about</a></li>
    <li class="navbar-item"><a href="#">settings</a></li>
    <li class="navbar-item"><a href="#">option1</a></li>
    <li class="navbar-item"><a href="#">option2</a></li>
    <li class="navbar-item"><a href="#">option3</a></li>
  </ul>
</nav>
Run Code Online (Sandbox Code Playgroud)

上海社会科学院:

.navbar
    float: left
    height: 40px
    min-width: 100%
    display: flex
    flex-wrap: wrap

    .navbar-item
        padding: 13px 0px
        font-size: 12px
        line-height: 14px
        text-transform: uppercase
        display: inline-block
        float: left
        margin: 0px 10px

        &.active
            padding: 13px 0px 11px 0px
            border-bottom: 2px solid $light-blue

        &:hover
            cursor: pointer

        a 
            color: $dark-grey
            font-weight: 600
            text-decoration: none
Run Code Online (Sandbox Code Playgroud)

Ama*_*ser 5

您可以使用:before:after元素。(width:100vh例如,在div上)您在屏幕左侧显示一个渐变,在屏幕右侧显示一个渐变。

  content:'';
  height: 100%;
  width: 15%;
  display:block;
  position: absolute;
  left: 0;
  background: rgba(255,255,255,1);
  background: -moz-linear-gradient(left, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
  background: -webkit-gradient(left top, right top, color-stop(0%, rgba(255,255,255,1)), color-stop(100%, rgba(255,255,255,0)));
  background: -webkit-linear-gradient(left, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
  background: -o-linear-gradient(left, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
  background: -ms-linear-gradient(left, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
  background: linear-gradient(to right, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ffffff', GradientType=1 );
Run Code Online (Sandbox Code Playgroud)

这样,您将在菜单的边缘徘徊。

精确一点,

.navbar应该有overflow-x: auto; white-space: nowrap;并且navbar-list应该是100%宽。