Skip to content

Instantly share code, notes, and snippets.

@lianyi
Forked from pom-pom/font-awesome-form-elements.css
Last active August 29, 2015 14:15
Show Gist options
  • Save lianyi/c35817e5eff0723795f8 to your computer and use it in GitHub Desktop.
Save lianyi/c35817e5eff0723795f8 to your computer and use it in GitHub Desktop.
/*Custom Radio Buttons and Checkboxes using Font Awesome*/
input[type=radio],
input[type='checkbox'] {
display: none;
}
input[type=radio] + label {
display: block;
}
input[type='checkbox'] + label:before,
input[type='radio'] + label:before {
display: inline-block;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
padding-right: 8px;
width: 23px;
}
input[type=radio] + label:before {
content: "\f10c"; /* Radio Unchecked */
}
input[type=radio]:checked + label:before {
content: "\f05d"; /* Radio Checked */
}
input[type="checkbox"] + label:before {
content: "\f096"; /* Checkbox Unchecked */
}
input[type="checkbox"]:checked + label:before {
content: "\f046"; /* Checkbox Checked */
}
.radio label,
.checkbox label {
padding-left: 0;
}
/*
HTML Markup should look like this:
<div class="checkbox">
<input type="checkbox" id="myCheckbox" name="myCheckbox" value="myCheckbox">
<label for="myCheckbox">Checkbox Label</label>
</div>
<div class="radio">
<input type="radio" id="myRadio" name="myRadio" value="myRadioOption">
<label for="myRadio">Label</label>
</div>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment