Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Radio Button Styling

I want to style radio buttons with pure CSS, no classes or IDs. Just input[type=radio]. I want to use a background image for unselected and selected. However, the -vendor-appearance:none; doesn't work with Trident or Gecko. Just Webkit. In those browsers you can see the background image as a background to the radio button but the button is still there rather than just displaying the image, how can I get rid of the button so just the background image displays. The fiddle: http://jsfiddle.net/7kScn/

like image 293
henryaaron Avatar asked Dec 16 '11 01:12

henryaaron


2 Answers

You can use a CSS2 selector trick to connect to a radio group and display other stuff immediately after.

See: http://jsfiddle.net/7kScn/1/

It's just a basic example, but it operates on the premise of hiding the input field and then styling the label immediately after it, giving it the effect that it's the actual thing you're checking.

like image 174
animuson Avatar answered Oct 21 '22 09:10

animuson


Is this of use? input[type=radio]:checked { border: 1px solid black; }

like image 37
James Alarie Avatar answered Oct 21 '22 09:10

James Alarie