How can I get rid of horizontal padding or indent in html5 search inputs in webkit on mac?

风流意气都作罢 提交于 2019-12-04 10:53:25

This is how you really reset the default styling in WebKit:

input[type="search"] {
    -webkit-appearance: textfield;
}

input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
}

After that the padding problem should be gone. If you also want to normalize the cancel button, which isn't there in non-WebKit browsers, add input[type="search"]::-webkit-search-cancel-button as selector for the second rule.

By default WebKit-based browsers using border-box model for input[type="search"]. And if you using traditional box-sizing (you are if you haven't declared any other model) you may experience strange padding and border behavior. Fix:

input[type="search"] {
box-sizing: content-box;
}

As for -webkit-appearance - try textarea (textfield) and none. In any case test your page on iOS device, to be sure that styling won't be different after input field being in focus (strange behavior, could be bug - i'm using iPhone 4S with stock iOS 6.0)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!