Styling attractive CSS/Radio Buttons
Styling Radio Buttons and Check Boxes across Browsers and Operating Systems is a relatively hard task, simply because of the way the elements are rendered by various browsers; integrating the design with your website’s is a bit harder. This is a fairly simple trick I haven’t seen mentioned in any of the CSS sites I’ve read recently.
A small demonstration to whet your appetite first:
The basic idea is to hide the form element (checkbox/radio button) and style the label instead using CSS. Thanks to the :checked selector, it’s possible to distinguish between the two label states by assigning styles to label and input:checked + label assuming that the label follows the checkbox/radio button in your html code. Using a for attribute in the code makes the complete label click-able, modifying the state of the associated element.
A simple trick to make beautiful form elements without having to use javascript: and the styling will in no way affect any server side or script based code because the state of the checkbox/radio button is maintained.
The code:
1 | |
Comments