javascript - How to hide scroll bar on mobile safari? - Stack Overflow

I made navbar usign jade:nav.navbar.navbar_whitediv.navbar__innerul.nav-listli.nav-list__item_darka(hre

I made navbar usign jade:

nav.navbar.navbar_white
    div.navbar__inner
        ul.nav-list
            li.nav-list__item_dark
                a(href="#") item 1
            li.nav-list__item_dark
                a(href="#") item 2
            li.nav-list__item_dark
                a(href="#") item 3
            li.nav-list__item_dark
                a(href="#") item 4

And I want it to be horizontally scrollable on mobile and hide the scroll bar. So I wrote the following scss:

.nav-list {
    padding: 15px 0;
    margin: 0;
    width: 100%;
    list-style: none;
    white-space: nowrap;
    overflow-x: scroll;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch!important; 
    -ms-overflow-style: -ms-autohiding-scrollbar!important;

    &::-webkit-scrollbar { 
        display: none !important;
        width: 0 !important;
        height: 0 !important;
        background-color: transparent;
    }

    &::-webkit-scrollbar-thumb {
        display: none !important;
    }
}

As you see, I tried every way I know to hide it. But it works only when I load the page for the first time. When I reload it the scrollbar appears again. I need help to fix it

I made navbar usign jade:

nav.navbar.navbar_white
    div.navbar__inner
        ul.nav-list
            li.nav-list__item_dark
                a(href="#") item 1
            li.nav-list__item_dark
                a(href="#") item 2
            li.nav-list__item_dark
                a(href="#") item 3
            li.nav-list__item_dark
                a(href="#") item 4

And I want it to be horizontally scrollable on mobile and hide the scroll bar. So I wrote the following scss:

.nav-list {
    padding: 15px 0;
    margin: 0;
    width: 100%;
    list-style: none;
    white-space: nowrap;
    overflow-x: scroll;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch!important; 
    -ms-overflow-style: -ms-autohiding-scrollbar!important;

    &::-webkit-scrollbar { 
        display: none !important;
        width: 0 !important;
        height: 0 !important;
        background-color: transparent;
    }

    &::-webkit-scrollbar-thumb {
        display: none !important;
    }
}

As you see, I tried every way I know to hide it. But it works only when I load the page for the first time. When I reload it the scrollbar appears again. I need help to fix it

Share Improve this question asked Mar 14, 2017 at 18:34 Benjamin TrepachkoBenjamin Trepachko 1112 silver badges12 bronze badges 3
  • Did you ever figure this out? No matter what I do I can't get the default mobile safari scroll bar to be invisible on my scrolling horizontal menu. – flyingL123 Commented Jul 12, 2017 at 19:41
  • Anything new on this? Having this issue as well. – Crashtor Commented Jul 20, 2017 at 11:08
  • @Crashtor Yes, I posted the answer – Benjamin Trepachko Commented Aug 9, 2017 at 12:03
Add a ment  | 

1 Answer 1

Reset to default 4

The crossbrowser way to solve this problem is to set bottom padding to .navbar__inner element and set fixed height (should be less than puted height of .navbar__inner) and overflow:hidden to outer element. So that the scrollbar will not be visible because it will be placed lower (and will be overlowed) than the bottom of outer element.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745389889a4625613.html

相关推荐

  • javascript - How to hide scroll bar on mobile safari? - Stack Overflow

    I made navbar usign jade:nav.navbar.navbar_whitediv.navbar__innerul.nav-listli.nav-list__item_darka(hre

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信