html - 当 WebView 应该适合页面时,从左到右摆动

标签 html css android-webview

遵循所有提示后here禁用滚动没有任何效果。

为什么我的 webview 会稍微向左或向右移动,而当它应该刚好适合页面而不需要任何水平滚动时?

左图:初始加载

右图:向左滑动后。

enter image description here ... enter image description here

HTML:

<html>
    ...
    <body id="visitorinfo">
        <div class="visitor">
            <div class='titlebox'><img src="../images/helloworld.png"/></div>
        </div>
    </body>
</html>

CSS:

#visitorinfo{
    max-width:500px;
    text-align:left;
    font-size:16px;
    display:block;
    overflow:hidden;
    margin:5px;
}
.titlebox{
    float:center;
    max-width:100%;
    padding:5px;
    text-align:center;
}
.titlebox img{
    width:100%;
}
.visitor{
    margin-bottom:35px;
    display:block;
    overflow:hidden;
    margin:5px 10px;
    word-wrap:break-word;
}

注意:图像和文本都会发生这种情况。另外,我省略了多余的“向右滑动”。

最佳答案

原因:来自here : "边距清除元素周围的区域(边框外)。"因此,由于 WebView 的网页填充区域是 border body 标签及其内部的所有内容,在其周围添加填充,导致左右(可能还有顶部和底部)滚动。

修复:只需删除#visitorinfomargin:5px;。可以看到here为什么这会起作用。

关于html - 当 WebView 应该适合页面时,从左到右摆动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23503389/

相关文章:

jquery - 我想更改在带有单选按钮的组合框 (<select>) 中选择的选项?

javascript - 如何在网页上嵌入 3D 对象?

android - WebResourceResponse的setstatuscodeandReasonPhrase方法之前使用了什么?

html - 如何使用android向webview显示html内容

android - 从 WebView 捕获 HTML 作为图像?

html - 表格单元格内的 <td> 标记在 IE 7 中创建换行符

javascript - 通过JS在表格内显示一个div,position absolute移动表格列

html - Float 属性不适用于 <p> 和 <img> 元素

html - 无法摆脱顶部和底部的阴影

html - 向已经存在的输入添加追加