Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Style all Inputs but checkbox and radio

I am trying to use a style where I use

input:not([type=checkbox]), input:not([type=radio]){ ... 

But clearly that won't work. How can I use the styles I have written for all inputs but just these two?

like image 382
e.shell Avatar asked Feb 07 '14 02:02

e.shell


People also ask

How do you style an input type radio?

In your code you need to add <label for="r2"><span></span>Radio Button 2</label> after creating radio and using my css code you can do this. @DipeshParmar using input[type="radio"] { display:none; } will take out keyboard access from the radio buttons.

Can I style checkbox in CSS?

It is possible to style a checkbox using Pseudo Elements like :before, :after, hover and :checked. To style the checkbox the user first needs to hide the default checkbox which can be done by setting the value of the visibility property to hidden. Example 1: Consider the example where HTML checkbox is styled using CSS.


1 Answers

You need to use a single combined selector instead of two selectors:

input:not([type=checkbox]):not([type=radio]) { ... } 

This selects any input element that does not have the attribute type=checkbox and that does not have the attribute type=radio. The code in the question, with two selectors, selects all input elements that do not have the attribute type=checkbox and additionally all input elements that do not have the attribute type=radio, so it ends up with selecting all input elements.

Usual CSS Caveats apply. You may wish to use polyfill like Selectivzr to cover old versions of IE.

like image 171
Jukka K. Korpela Avatar answered Sep 20 '22 18:09

Jukka K. Korpela