Radio Button Styling
Solution 1
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.
Solution 2
Is this of use? input[type=radio]:checked { border: 1px solid black; }
henryaaron
Updated on August 09, 2022Comments
-
henryaaron almost 2 years
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/
-
henryaaron over 12 yearsCSS3? :( it's an ecommerce site, none of the functionality can be based on CSS3 just the style. If it falls back to just display the checkboxes like it normally would than that's acceptable, but if you're calling
display:none;
than I can't really use that. -
animuson over 12 yearsAccording to this compatibility chart, this specific selector should work fine in its current state. It's only unsupported in IE6 (those notes about static for IE7/8 don't affect this use of it). It appears to have been CSS2 (?).
-
henryaaron over 12 yearsBut my site doesn't use labels, how would it work without the + label
-
animuson over 12 yearsYou can't remove the actual box from them with CSS, that is what the radio/checkbox is. The only other solution would be to use JavaScript to modify the HTML there to make them fancy.
-
henryaaron over 12 yearsJust checked with Adobe BrowserLab, works in IE7 + in IE6 falls back to standard visibility. That's great, now what about the labels is there a workaround?