ios - 移除 iOS 输入阴影

标签 ios css input

在 iOS (Safari 5) 上,我必须遵循输入元素(顶部内阴影):

example

我想移除顶部阴影,错误 -webkit-appearance 没有保存。

当前样式是:

input {    
    border-radius: 15px;
    border: 1px dashed #BBB;
    padding: 10px;
    line-height: 20px;
    text-align: center;
    background: transparent;
    outline: none;    
    -webkit-appearance: none;
    -moz-appearance: none;
}

最佳答案

您需要使用 -webkit-appearance: none; 来覆盖默认的 IOS 样式。但是,仅选择 CSS 中的 input 标签不会覆盖默认的 IOS 样式,因为 IOS 通过使用属性选择器 input[type=text] 添加它的样式。因此,您的 CSS 将需要使用属性选择器来覆盖已预先设置的默认 IOS CSS 样式。

试试这个:

input[type=text] {   
    /* Remove First */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    /* Then Style */
    border-radius: 15px;
    border: 1px dashed #BBB;
    padding: 10px;
    line-height: 20px;
    text-align: center;
    background: transparent;
    outline: none;    
}

有用的链接:

您可以在此处了解有关外观的更多信息:

http://css-tricks.com/almanac/properties/a/appearance/

如果您想了解有关 CSS 属性选择器的更多信息,可以在此处找到内容丰富的文章:

http://css-tricks.com/attribute-selectors/

关于ios - 移除 iOS 输入阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23211656/

相关文章:

iphone - UIFileSharingEnabled 使用文件夹

c++ - 在 C++ 中从文件生成符号表

css - 单击时删除输入突出显示的框

ios - 从 NSDate 获取百分之一秒的差异

ios - branch.io - 参数 +is_first_session 始终为 false

ios - 定义 UIImage 将使用的文件 (Swift)

具有一个输入字段的 PHP 计算器

html - 使用伪类进行高级布局

html - 如何避免 sass partials 生成冗余的 css 代码?

javascript - jQuery .slideToggle() 重复