为什么输入框在Ipad上显示如此不同而在Chrome上不显示

ash*_*osh 1 css css3 border-color border-layout ipad

我有一个正常工作的网站,除了输入字段和旁边的提交按钮.它们在iPad上无法正常显示.输入框的高度略高于提交按钮,使其看起来很奇怪.

我个人认为iPad是safari-mobile,有不同的视口(1024px)等,但呈现与Chrome相同的webkit外观.那么为什么iPad上的输入框显示不同?


以下是我在桌面上使用Google Chrome浏览器的外观:

桌面版输入框

以下是它在iPad上的外观:

iPad上的相同输入框

HTML部分简单如下:

<div id="search-form">
    <input id="Search" class="defaultText defaultTextActive" title="search shzamm!" type="text" spellcheck="false">
    <input onclick="javascript:someFunction();" type="button" value="Go" class="search_btn">
</div>
Run Code Online (Sandbox Code Playgroud)

同样的CSS是:

#search-form {
    overflow: auto;
    box-shadow: -1px 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 26px;
}

input#Search {
    -webkit-appearance: none;
    border-radius: 0;
    -webkit-border-radius: 0;
}

.defaultText {
    width: 88%;
    padding-left: 4px;
    height: 29px;
    float: left;
    background-color: #f7f7f7;
    border-right: 0px solid #666;
    border-bottom: 1px solid #666;
    border-color: #999;
    margin-right: -33px;
}

.defaultTextActive {
    color: #999;
    font-style: italic;
    font-size: 15px;
    font-weight: normal;
}

.search_btn {
    font-size: 13px;
    font-weight: bold;
    height: 34px;
    cursor: pointer;
    float: right;
    margin: 0;
    width: 33px;
    background: url("../images/search.jpg") no-repeat;
    text-indent: -99999px;
    border: 1px solid #999;
    border-top: 2px solid #000;
    margin-top: 0px;
    margin-right: 1px;
}
Run Code Online (Sandbox Code Playgroud)

如您所见,输入的边框效果也未在iPad中正确呈现.任何人都有任何线索吗?

小智 5

尝试使用-webkit-appearance摆脱默认样式。

检查这个答案:iOS强制输入圆角和眩光

  • 我这样做了 - 它有帮助,但是 ios 上的输入字段仍然比浏览器中的要高......什么给出了? (3认同)

crm*_*cco 5

这段CSS将从文本框中删除默认的WebKit样式:

input[type="text"] {
    -webkit-appearance : none;
    border-radius      : 0;
}
Run Code Online (Sandbox Code Playgroud)

适用于iOS 7.