【问题标题】:Avoid scrolling the page with touch while navbar is open避免在导航栏打开时触摸滚动页面
【发布时间】:2017-03-08 21:56:19
【问题描述】:

在移动 Chrome 中,当我在打开的 navbar 上触摸滚动时,页面会滚动到它后面,这很烦人。另外,当我的navbar有很多item时,它也会滚动,当到达顶部或底部时,页面会继续滚动,这更烦人,整体用户体验也很差。

有什么方法可以在.navbar-collapse 容器中捕获触摸滚动事件,这样它们就不会影响到其中的任何内容?

到目前为止我尝试过的是这样的

$(".navbar-collapse").on("touchmove", function(e) { e.stopPropagation(); });

但似乎无效,我猜这种行为在浏览器中要深得多。

【问题讨论】:

    标签: javascript twitter-bootstrap twitter-bootstrap-3


    【解决方案1】:

    尝试将其添加到您的自定义 css 中

    @media(max-width:780px)
    {
    .navbar
     {
           position: absolute;
    width: 100%;
    max-height: 500px;
    overflow-x: hidden;
    overflow-y: scroll;
     }
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-07
      • 1970-01-01
      • 2018-09-27
      • 1970-01-01
      • 2014-12-14
      • 2011-07-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多