【问题标题】:Mobile Website Wont Scroll Although Scrollbar is appearing尽管出现滚动条,但移动网站不会滚动
【发布时间】:2015-02-28 21:53:14
【问题描述】:

我正在建立一个使用响应式 wordpress 主题的新网站。

网站网址是 - www.render-box.co.uk/new/

该网站在缩小到移动设备大小时看起来不错,但在移动设备上查看时我无法向下滚动。滚动条出现在页面的一侧。

好像有什么东西阻止了页面滚动,我不太确定是什么?

谢谢

【问题讨论】:

    标签: jquery wordpress mobile web scroll


    【解决方案1】:

    好的。如果您检查代码,则会有一个脚本在 HTML 标记中放置:“overflow:hidden”。 (我猜是因为自定义滚动条,实际上是 niceScroll 插件做的,它不适用于移动设备)......所以,你可以编写一个脚本来覆盖 nicescroll。

    我为你做了这个,这将检查 UserAgent 以检测用户是否在移动设备上,然后覆盖 html 标记的 css 规则。希望这对你有用。

        $(function(){
    
            var movil=false;
    
            if( navigator.userAgent.match(/Android/i) || 
                navigator.userAgent.match(/webOS/i) ||
                navigator.userAgent.match(/iPhone/i) || 
                navigator.userAgent.match(/iPad/i)|| 
                navigator.userAgent.match(/iPod/i) || 
                navigator.userAgent.match(/BlackBerry/i)){
    
                var movil=true;
    
            }
    
            else{
                var movil=false
            }
    
    
            if(movil==true){
    
                // SET OVERFLOW TO AUTO, SO THE SCROLL IT'S ALLOWED
    
                $("html").css("overflow", "auto");
    
                //HIDE THE NICESCROLL FOR MOBILE DEVICES 
    
                $("#ascrail2000").css("display", "none");
    
    
            }
    
            else{}
        });
    

    不要忘记把它放在 html 末尾的标签上,当 DOM 准备好时,它会覆盖 css。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-22
      • 2014-06-11
      • 1970-01-01
      相关资源
      最近更新 更多