Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide check radio button with css

I would like to know if it is possible to hide the checked radio button with css by using:

  { display:none; } 

I don't know how to address this element. The checked radio button always displays "none" which does not mean anything to the user and I wish to hide it. Is this possible? Thanks for any pointer.

like image 343
bertassa Avatar asked Aug 06 '13 11:08

bertassa


People also ask

How do I uncheck a radio button in CSS?

The :checked CSS pseudo-class selector represents any radio ( <input type="radio"> ) element that is checked. The idea is to use the :checked selector to identify the selected radio button and unset it.

How do you show and hide input fields based on radio button selection?

To show or hide an element when a radio button is selected: Add a click event handler to all input elements of type radio . Each time a radio button is selected, check if it is the button that should show the element. If it is, set the display property of the hidden element to block .

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.


1 Answers

Just a little tip:

If you still want to use all the browser's native support for radios and check boxes, like moving between them with ↑ and ↓ keys, set the css to:

position: fixed; opacity: 0; pointer-events: none; 

This will keep all functionality but keep the input hidden, and won't take up any layout space.
I've spent the last 3 hours figuring this out, but it does work!

like image 120
Joe H Avatar answered Sep 28 '22 09:09

Joe H