Created
August 16, 2018 00:47
-
-
Save m1ndspark/e864ff9e83e46de8271febd6e287e60d to your computer and use it in GitHub Desktop.
Use Font Awesome Icons for Your Website Checkboxes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* hide the OS/browser checkboxes/radio buttons */ | |
input[type=checkbox], input[type=radio] { | |
visibility: hidden; | |
margin: 0; | |
width: 0!important; | |
} | |
input[type=checkbox] + label:hover, input[type=radio] + label:hover { | |
cursor: pointer; | |
} | |
/* set FontAwesome and positioning */ | |
input[type=checkbox] + label:before, input[type=radio] + label:before { | |
font-family: "FontAwesome"; | |
font-size: 20px; | |
position: relative; | |
margin-right: 0.7em; | |
} | |
/* Gravity Forms tweaks - change for your forms plugin */ | |
.gform_wrapper li.gf_list_inline ul.gfield_checkbox li, | |
.gform_wrapper li.gf_list_inline ul.gfield_radio li { | |
display: -moz-inline; | |
display: inline; | |
} | |
/* set checkbox icons and opacities for normal, hover, and checked */ | |
input[type=checkbox] + label:before { content: "\f096"; } | |
input[type=checkbox] + label:hover:before { content: "\f046"; filter: alpha(opacity=30); opacity: 0.3; } | |
input[type=checkbox]:checked + label:before { content: "\f046"; } | |
input[type=checkbox]:checked + label:hover:before, input[type=radio]:checked + label:hover:before { filter: alpha(opacity=100); opacity: 1; } | |
/* set radio button icons and opacities for normal, hover, and checked */ | |
input[type=radio] + label:before { content: "\f10c"; } | |
input[type=radio] + label:hover:before { content: "\f192"; filter: alpha(opacity=30); opacity: 0.3; } | |
input[type=radio]:checked + label:before { content: "\f192"; } | |
input[type=radio]:checked + label:hover:before { filter: alpha(opacity=100); opacity: 1; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment