Skip to content

Instantly share code, notes, and snippets.

@jimmy89Li
Created March 3, 2017 10:59
Show Gist options
  • Save jimmy89Li/3dc31254b7e605103fdff9623a8ee79c to your computer and use it in GitHub Desktop.
Save jimmy89Li/3dc31254b7e605103fdff9623a8ee79c to your computer and use it in GitHub Desktop.
css new style for radio buttons
<label for="accessible">
<input type="radio" value="accessible" name="quality" id="accessible"> <span>accessible</span>
</label>
<label for="pretty">
<input type="radio" value="pretty" name="quality" id="pretty"> <span>pretty</span>
</label>
<label for="accessible-and-pretty">
<input type="radio" value="pretty" name="quality" id="accessible-and-pretty" checked> <span>accessible and pretty</span>
</label>
/* HTML5 Boilerplate accessible hidden styles */
[type="radio"] {
border: 0;
clip: rect(0 0 0 0);
height: 1px; margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
/* One radio button per line */
label {
display: block;
cursor: pointer;
line-height: 2.5;
font-size: 1.5em;
background: #85b85c;
margin: 10px 0;
padding: 10px;
border: 3px solid #ccc;
}
/* the basic, unchecked style */
[type="radio"] + span:before {
content: '';
display: inline-block;
width: 1em;
height: 1em;
vertical-align: -0.25em;
border-radius: 1em;
border: 0.125em solid #ccc;
box-shadow: 0 0 0 0.14em #ccc;
margin-right: 0.75em;
transition: 0.5s ease all;
}
/* the checked style using the :checked pseudo class */
[type="radio"]:checked + span:before {
background: #fff;
border: 0.125em solid #85b85c;
box-shadow: 0 0 0 0.23em #fff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment