问题
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