0

I want to display list of menu by scrolling horizontally. So I have written code as:

.sub-menu {
    overflow-x: scroll;
    overflow-y: hidden;
    white-space:nowrap;
}

.menu.navbar-nav li{
    width: 22%;
    text-align: center;
    display:inline-block;
    vertical-align:top;
}

But it is showing a bar horizontally but I want to disappear it. Please see the image.

Could you tell me someone how can I remove it.

HTML

<div class="mobile-menu temp-mobile-menu visible-xs">
<div class="sub-menu">
    <ul class="menu nav navbar-nav" id="">
        <li class="active"><a href="/bn" class="first leaf home active">Home</a></li>
        <li><a href="/bn/tonic-doctor" class="leaf doctor">Doctor</a></li>
        <li><a href="/bn/tonic-benefits" class="leaf benefits">Benefits</a></li>
        <li><a href="/bn/packages" class="leaf packages">Packages</a></li>
        <li><a href="/bn/health-topics" style="swiper-slide" class="last leaf স্বাস্থ্য-প্রসঙ্গ">স্বাস্থ্য প্রসঙ্গ</a></li>
    </ul>    
</div>
</div>

Updated CSS

.mobile-menu {
  overflow: hidden;
}
.sub-menu {
  min-height: 44px;
  white-space: nowrap;
  overflow-x: scroll;
}
.menu.navbar-nav li {
 width: 22%;
 text-align: center;
 display: inline-block;
 vertical-align: top;
}
StreetCoder
  • 9,103
  • 7
  • 36
  • 55

2 Answers2

2

overflow-x: scroll; means that your horizontal scroll bar is visible.

If you want to remove it, use overflow-x: hidden;

By the way, if you want both horizontal and vertical scrollers to be hidden, just use: overflow: hidden;

If you want to hide the scrollbar but keep scrolling capabilities, add a div with a CSS class called maindiv above your sub-menu element and use:

.maindiv{       
    overflow: hidden;
}

.sub-menu{
    width: 100%;
    height: 100%;
    overflow-x: scroll;
    padding-bottom:20px;
}
Koby Douek
  • 14,709
  • 15
  • 58
  • 84
1

Try to change overflow-x: scroll; to overflow-x: hidden; in your .sub-menu class

EDIT: Add this class to CSS file:

::-webkit-scrollbar { 
width: 0px; /* remove scrollbar space */ 
background: transparent; /* optional: just make scrollbar invisible */ 
}

Working JSFiddle example

Marco
  • 113
  • 1
  • 7