Last active
May 8, 2019 03:14
-
-
Save wpmonks/7310438b5a41bf0c0e71c7651b129705 to your computer and use it in GitHub Desktop.
how to design checkbox in CSS
This file contains 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
body #gform_wrapper_FORMID .gfield_checkbox li input[type=checkbox] { | |
opacity: 0; | |
position: absolute; | |
} | |
body #gform_wrapper_FORMID .gfield_checkbox li input[type=checkbox] + label{ | |
position: relative; | |
overflow: hidden; | |
padding-left: 35px; | |
cursor: pointer; | |
display: inline-block; | |
} | |
body #gform_wrapper_FORMID .gfield_checkbox li input[type=checkbox] + label:before, | |
body #gform_wrapper_FORMID .gfield_checkbox li input[type=checkbox] + label:after{ | |
content: ''; | |
position: absolute; | |
left: 0; | |
z-index: 1; | |
-webkit-transition: .2s; | |
transition: .2s; | |
} | |
/* after */ | |
body #gform_wrapper_FORMID .gfield_checkbox li input[type=checkbox]:not(:checked) + label:after{ | |
width: 20px; | |
height: 20px; | |
border: 2px solid #000; | |
top: 0px; | |
} | |
body #gform_wrapper_FORMID .gfield_checkbox li input[type=checkbox]:checked + label:after{ | |
top: 0; | |
width: 20px; | |
height: 20px; | |
border: 2px solid #26a69a; | |
background-color: #26a69a; | |
z-index: 0; | |
border-radius: 2px | |
} | |
/* before */ | |
body #gform_wrapper_FORMID .gfield_checkbox li input[type=checkbox]:not(:checked) + label:before{ | |
width: 0; | |
height: 0; | |
border: 3px solid transparent; | |
left: 6px; | |
top: 10px; | |
-webkit-transform: rotateZ(37deg); | |
transform: rotateZ(37deg); | |
-webkit-transform-origin: 100% 100%; | |
transform-origin: 100% 100%; | |
} | |
body #gform_wrapper_FORMID .gfield_checkbox li input[type=checkbox]:checked + label:before{ | |
top: 0; | |
left: 1px; | |
width: 8px; | |
height: 13px; | |
margin-top:3px; | |
border-top: 2px solid transparent; | |
border-left: 2px solid transparent; | |
border-right: 2px solid #fff; | |
border-bottom: 2px solid #fff; | |
-webkit-transform: rotateZ(37deg); | |
transform: rotateZ(37deg); | |
-webkit-transform-origin: 100% 100%; | |
transform-origin: 100% 100%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment