I have a simple solution in which I have a shortcut surrounding my radio buttons with an image representing the selected thing:
<label> <input type="radio" name="foo"> <img src="..."> </label>
I applied the following styles:
label { float: left; width: 100px; height: 100px; position: relative; cursor: pointer; } label input[type=radio] { opacity: 0; } label img { position: absolute; top: 0; left: 0; opacity: 0.5; } :checked + img { opacity: 1; }
Essentially, each label becomes a regular-sized box that is completely filled with img . The radio itself is hidden using opacity:0 . The user can indicate what is selected, since img next to the checked radio will be opaque, while others will be translucent. You can easily make various other effects.
I like the fact that the form remains easy to process, it is a group of switches.
I used opacity for the switches, not display:none or visibility:hidden , since they are still in tabindex and the form remains accessible to the keyboard.
Rob fletcher
source share