PhoneGap/Cordova:防止水平滚动

Mel*_*Dog 8 html scroll cordova

我有一个建立在Cordova上的应用程序,在我的一些页面上,我能够从我的内容水平滚动到空白区域.

这很奇怪,因为我在那里没有任何东西超出了我的#wrapper设定范围width: 100%.

所以我想知道是否有一种方法可以完全禁用应用程序中的水平滚动?

更新:

请求页面上的代码:

body {
    background-color: #fff;
    font-family:Arial, Helvetica, sans-serif;
    color: #b7b8b9;
    height: 100%;
    width: 100%;
}

iframe{
    border: none;
    width: 100%;
    /*margin-top: 50px;*/


   }

#header{
    height: 50px;
    width: 100%;
}


<body>
         <div id="wrapper">
        <div id="header">
            <div class="headerback"><a href="index.html">Home</a></div>
            <div class="headerrefresh"><script>var pathname = window.location.pathname;</script><script>document.write('<a href="'+pathname+'">Refresh</a>')</script></div>
            <div class="headertitle"><h2>Get the Look</h2></div>

        </div><!--HEADER-->
    <iframe src="http://www.mbff.com.au/getthelook"></iframe>
    </div>
    </body>
Run Code Online (Sandbox Code Playgroud)

这是在水平滚动上发生的事情

Jus*_*ijn 7

尝试使用设备的确切尺寸在Chrome(webkit)中调试您的网页.这解决了我的大多数渲染问题.

我不知道这里的具体问题,但看起来你的一个元素正在包装外流动.你可以试试这个css:

div.wrapper { overflow: hidden; width: inherit; }
Run Code Online (Sandbox Code Playgroud)

虽然找出页面水平扩展的原因可能更好一点?


小智 6

我很长时间都在寻找这个问题的解决方案.最后我用以下方式解决了它.我设置样式bodyhtml标签:

position: fixed;
width: 100%;
height: 100%;
overflow: hidden;
Run Code Online (Sandbox Code Playgroud)

从那以后,我已经添加divbody并设置样式为它:

overflow-y: auto;
height: 100%;
Run Code Online (Sandbox Code Playgroud)

所以,我有固定的身体,其中包含div与垂直滚动条.