iphone - 仅 iPad/iPhone 中的 CSS 搜索框对齐问题

标签 iphone css ipad height alignment

我在对齐 CSS 搜索输入框时遇到问题,就像在这个 tutorial page 上找到的 Google 风格一样.

我已经编辑了代码以适合我的设计,但出于某种原因,我无法使其在 iPhone/iPad 中正确对齐,右侧元素未与底部的左侧元素对齐。

The alignment issue can be seen here

代码如下:

HTML:

<div id="search">
    <form name="" action="" type="">
    <input type="text" name="field" id="field" />
    <div id="delete"><span id="x">x</span></div>
    </form>
</div>

CSS:

#search {float:left; margin:11px 0 0 156px;}
#field {float:left;width:200px; height:22px; line-height:22px; text-indent:0px; font-family:arial,sans-serif; font-size:12px; color:#999; background: #fff; background:url('search-icon.png') no-repeat left center; padding-left:25px; border:solid 1px #d9d9d9; border-right:none; -webkit-appearance:none; -webkit-border-radius:0px;}
#field:focus {outline:none;}
#delete {float:left; width:16px; height:24px; line-height:22px; padding:0 0 0 6px; font-family:"Lucida Sans", "Lucida Sans Unicode",sans-serif; font-size:14px; background:#FFFFFF; border:solid 1px #D9D9D9; border-left:none; -webkit-appearance:none; -webkit-border-radius:0px;}
#delete #x {color:#999999; cursor:pointer; display:none; }
#delete #x:hover {color:#666666;}

我注意到下面改变了高度:24px:

#delete {float:left; width:16px; height:24px; line-height:22px; padding:0 0 0 6px; font-family:"Lucida Sans", "Lucida Sans Unicode",sans-serif; font-size:14px; background:#FFFFFF; border:solid 1px #D9D9D9; border-left:none; -webkit-appearance:none; -webkit-border-radius:0px;}

至高度:27px;在 iPad/iPhone 上的 Safari 中正确对齐,但在 IE/FF/Chrome 上无法正确显示。

任何帮助将不胜感激。谢谢

最佳答案

我在本地测试过它可以工作,如果您在页面顶部添加以下内容,那么问题应该得到解决。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

关于iphone - 仅 iPad/iPhone 中的 CSS 搜索框对齐问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9371622/

相关文章:

html - 具有不同图像大小的 Bootstrap 响应式网格问题

iphone - iOS Development : When receiving a Game Center invite, 如何获取GKMatch对象?

ios - 获取 <command line> 错误 - 找不到 info.plist 文件

iphone - 将按钮动态添加到 uitableviewcell - iPhone 应用程序

ios - 设备上的 PureLayout : unrecognized selector sent to instance

html - 如何更改 DataTables 文本 `Showing page 1 of 5 of x entries`?

html - 将一个段落元素移动到另一个段落元素旁边

ios - 如何在 iOS 上录制对话/电话?

objective-c - 应用程序可以在模拟器上运行,但不能在 iPad 上运行

ios - 按钮未对齐的 Storyboard 弹出框