Last active
December 17, 2015 23:42
-
-
Save abbotto/e92ec2c334ca79b7f1a2 to your computer and use it in GitHub Desktop.
Cross-Browser Form Controls - Made with SASS and Font Awesome
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
// Demo: http://codepen.io/o0110o/pen/ZQWLKR?editors=110 | |
// Comment out the following line if you already have Font Awesome installed | |
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css); | |
// Base Style | |
.icon { | |
text-decoration: none; | |
margin-left: 0.4rem; | |
&:before { | |
position: relative; | |
left: -0.4rem; | |
font-family: "FontAwesome"; | |
} | |
} | |
// Font-Awesome form controls for radios and checkboxes | |
input[type="checkbox"], | |
input[type="radio"] { | |
display: none; | |
} | |
input[type="checkbox"] + label { | |
@extend .icon; | |
&:before { | |
content: "\f096"; | |
} | |
} | |
input[type="checkbox"]:checked + label { | |
&:before { | |
content: "\f046"; | |
} | |
} | |
input[type="radio"] + label { | |
@extend .icon; | |
&:before { | |
content: "\f10c"; | |
} | |
} | |
input[type="radio"]:checked + label { | |
&:before { | |
content: "\f192"; | |
} | |
} | |
// EXAMPLE HTML | |
// <input id="my-input" name="my-input" type="radio" value="my-value"> | |
// <label class="radio" for="my-input"> | |
// My Input | |
// </label> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment