Skip to content

Instantly share code, notes, and snippets.

@colynb
Created December 22, 2011 03:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save colynb/1508781 to your computer and use it in GitHub Desktop.
Save colynb/1508781 to your computer and use it in GitHub Desktop.
Radio Button Hack - CSS Only
input[type=radio] {
position: absolute;
top: -9999px;
left: -9999px;
}
label {
cursor: pointer;
text-align: center;
font-family: sans-serif;
font-size: 14px;
font-weight: bold;
color: #ccc;
line-height: 40px;
height: 40px;
width: 40px;
float: left;
background-color: #eee;
border-radius: 100px;
margin-right: 10px;
}
input#toggle1[type=radio]:checked ~ label[for="toggle1"] {
background: blue;
color: #fff;
}
input#toggle2[type=radio]:checked ~ label[for="toggle2"] {
background: blue;
color: #fff;
}
<input type="radio" id="toggle1" name="toggle" value="1" /><label for="toggle1">1</label>
<input type="radio" id="toggle2" name="toggle" value="2" checked="checked" /><label for="toggle2">2</label>
{"view":"split-vertical","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment