Remove default browser styles on form elements

依然范特西╮ 提交于 2019-12-06 07:39:58

Short answer: you can't.

Long answer: you can, but expect pain.

I've hacked together nice looking Radio buttons, Checkboxes and Selects with 'sleight of hand' javascript + css. Basically, just after an input is loaded I hide it and replace it with labels / divs with events bound to them to make them act like they're the right inputs, and css to make them look that way. The events also update the underlying input so that the correct values are submitted with the rest of the form. If my script barfs or JS is off, the user gets the normal controls.

It wasn't that fun but the result is passable.

I do not look forward to seeing the mess IE makes of it though :)

I had inspiration from:

http://sourceforge.net/projects/selectreplace/?showfeed=code

This is an old question now but adding the CSS rule -webkit-appearance:none may help remove default Webkit styling, e.g. pill shaped buttons on Mobile Safari.

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