html - 位置宽度 :absolute input tag not correct on iPad

标签 html css ipad

我正在尝试将一个输入元素定位在一个 div 中,并带有背景,我需要对其进行绝对大小和定位。它在 PC 上运行正常,但如果不使用完全不同的值,我就无法在 iPad 上正常运行。

PC 上的外观

Appearence on PC

iPad 上的外观

enter image description here

HTML:

<div id="container">
    <input class="input-pc" type="text"/>
</div>
<br/>
<div id="container">
    <input class="input-ipad" type="text"/>
</div>

CSS:

#container{
    background-color: #343434;
    position: relative;
    width: 200px;
    height: 26px;
}

.input-pc {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 196px;
    height: 20px;
    background-color: #E8FB46;
    border: none;
}

.input-ipad {
    -webkit-appearance: none;
    -webkit-border-radius:0;
    position: absolute;
    left: 2px;
    top: 2px;
    width: 186px;
    height: 17px;
    background-color: #E8FB46;
    border: none;
}

Here is a fiddle这两种风格适用于 PC 和 iPad。

有没有办法让两个输入框在两个平台上都正确包含?

最佳答案

我还没有对此进行测试,但我想这应该适用于两种设备,因为我没有使用任何相对/绝对定位。相反,我只使用简单的 CSS。这是 html:

<div id="newContainer">
    <input class="input" type="text"/>
</div>

这是CSS:

* {
    margin:0;
    padding:0;
}

div {
    margin:20px 0 0 20px;
}
#newContainer{
    background-color: #343434;
    width: 200px;
    height: 23px;
    padding:1px 2px 0px 2px;
    border:0;
}

.input {
    width: 100%;
    height: 20px;
    background-color: #E8FB46;
    border: none;
}

您可以在这里看到:http://jsfiddle.net/6mVHJ/2/

希望这有帮助!!!

关于html - 位置宽度 :absolute input tag not correct on iPad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24249934/

相关文章:

javascript - 如何在无序列表中缩进换行?

javascript - 如何动态地将图案图像添加到 svg 中?

html - 使用div标签在html中显示文本

iphone - 更改 tableView 的框架导致我的应用程序出现问题

javascript - 单击链接时桌面菜单隐藏

html - 在不突出的情况下裁剪图像部分

iphone - 当服务器在谷歌云上时,websocket 在 iPad、iPhone 上失败

ios - modalPresentationStyle 在 iOS5 的模态视图中不起作用

javascript - Jquery clickevent 不工作

css - 在 html5 中显示新闻列表的最佳实践