Dawid Zbiński Dawid Zbiński - 1 month ago 12
CSS Question

Horizontal menu with fade effect on overflow

I'm using CSS3/SASS and I wouldn't like to use any Javascript if possible. I'm trying to make a horizontal menu where overflow-x would make nice fade effect on the right side, so the user on mobile devices would know that he can move it left-right.

Here is what I'm trying to accomplish:

nice fade on the right side text

... as you can see on the picture the text on the right side is being faded out a bit and there, of course, is an OPTION3 menu item (so it's overflowed).

So far I got the menu, but I really have no idea about the overflows and the tricks with them.


<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>


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

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

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

cursor: pointer

color: $dark-grey
font-weight: 600
text-decoration: none


You can use the :before and :after elements. (on a div with width:100vh for example) You display one gradient on the left of your screen, and one on the right.

  height: 100%;
  width: 15%;
  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 );

This way, you will have a gradient hovering the edges of your menu.