Why does input[type=checkbox] not allowing CSS?

笑着哭i 提交于 2020-01-06 05:31:30

问题


I am trying to find direct CSS to apply for checkbox. But I could only find the hacks for styling checkbox or radio button. Unlike input[type=button] or [type=text], why would checkbox or radio button not allow the native CSS styles?


回答1:


You can't directly style checkbox or radio input. It's styled by browser. If you want to do some customization, you need to hide it, and style it through pseudo element like :before/:after or just use a span etc..

Here are som simple examples: https://www.w3schools.com/howto/howto_css_custom_checkbox.asp



来源:https://stackoverflow.com/questions/52033419/why-does-inputtype-checkbox-not-allowing-css

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