- The
inputhas to go before thelabel, at the same level - The
inputissr-onlyallow tab focus - The
idandforattributes need to be well defined so that thelabelcan properly check and uncheck the input when you click on it - The label has a
:beforepseudo-element that mimics the checkbox appearance - Using the CSS selector
:checkedwe can style the checked appearance
Last active
June 7, 2016 16:19
-
-
Save javierartero/fc77e36b8c6807da7fa54f91e2b6117a to your computer and use it in GitHub Desktop.
Checkbox
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
| $checkbox-color-active: $brand-primary !default | |
| $checkbox-color-scale-active: 1.1 !default | |
| $checkbox-box-size: 1.2em !default | |
| $checkbox-box-top: 0.05em !default | |
| $checkbox-box-padding: $checkbox-box-size + .75em !default | |
| .checkbox | |
| input[type="checkbox"] | |
| @extend .sr-only | |
| + label | |
| display: inline-block | |
| padding-left: $checkbox-box-padding | |
| position: relative | |
| z-index: 1 | |
| &:before | |
| @extend .fa | |
| content: '' | |
| display: block | |
| position: absolute | |
| top: $checkbox-box-top | |
| left: $checkbox-box-size/4 | |
| width: 1em | |
| height: 1em | |
| font-size: $checkbox-box-size | |
| border: 1px solid | |
| border-radius: 2px | |
| transition: all 0.3s ease-out | |
| transform: scale(1) | |
| &:hover:before | |
| border-color: $checkbox-color-active | |
| color: $checkbox-color-active | |
| transform: scale($checkbox-color-scale-active) | |
| &:focus | |
| + label:before | |
| border-color: $checkbox-color-active | |
| color: $checkbox-color-active | |
| transform: scale($checkbox-color-scale-active) | |
| &:checked | |
| + label:before | |
| content: "\f14a" //font-awesome | |
| border: 0 | |
| transform: scale(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment