Last active
April 1, 2019 11:43
-
-
Save gladchinda/7b619f1861b0a9e4bc93a5485f9ca041 to your computer and use it in GitHub Desktop.
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
/* Styles for hiding the native checkbox */ | |
input[type='checkbox'].check-custom { | |
position: absolute; | |
left: -10000px; | |
top: auto; | |
width: 1px; | |
height: 1px; | |
overflow: hidden; | |
} | |
/* Styles for the basic appearance of the toggle switch */ | |
input[type='checkbox'].check-custom.toggle-switch ~ .check-toggle { | |
width: 1.5rem; | |
height: 1rem; | |
position: relative; | |
display: inline-block; | |
vertical-align: middle; | |
cursor: pointer; | |
} | |
/* Common styles for the ::before and ::after pseudo-elements of the toggle switch */ | |
input[type='checkbox'].check-custom.toggle-switch ~ .check-toggle::before, | |
input[type='checkbox'].check-custom.toggle-switch ~ .check-toggle::after { | |
content: ''; | |
top: 0; | |
left: 0; | |
position: absolute; | |
} | |
/* Styles for the ::before pseudo-element (the outer frame) of the toggle switch */ | |
input[type='checkbox'].check-custom.toggle-switch ~ .check-toggle::before { | |
width: 100%; | |
height: 100%; | |
border-radius: 0.5rem; | |
background: #dbdbdb; | |
} | |
/* Styles for the ::after pseudo-element (the inner slider) of the toggle switch */ | |
input[type='checkbox'].check-custom.toggle-switch ~ .check-toggle::after { | |
width: 0.75rem; | |
height: 0.75rem; | |
margin: 0.125rem; | |
border-radius: 50%; | |
background: #ffffff; | |
} | |
/* Styles for the ::before pseudo-element of the toggle switch in hover state */ | |
input[type='checkbox'].check-custom.toggle-switch:hover ~ .check-toggle::before { | |
background: #c4c4c4; | |
} | |
/* Styles for the ::before pseudo-element of the toggle switch in focus state */ | |
input[type='checkbox'].check-custom.toggle-switch:focus ~ .check-toggle::before { | |
box-shadow: 0 0 0 2px rgba(23, 133, 255, 0.5); | |
} | |
/* Styles for the ::before pseudo-element of the toggle switch in both focus and checked or enabled state */ | |
input[type='checkbox'].check-custom.toggle-switch:focus:checked ~ .check-toggle::before { | |
box-shadow: 0 0 0 2px rgba(97, 191, 158, 0.5); | |
} | |
/* Styles for the ::before pseudo-element of the toggle switch in checked or enabled state */ | |
input[type='checkbox'].check-custom.toggle-switch:checked ~ .check-toggle::before { | |
background: #61bf9e; | |
} | |
/* Styles for the ::after pseudo-element of the toggle switch in checked or enabled state */ | |
input[type='checkbox'].check-custom.toggle-switch:checked ~ .check-toggle::after { | |
left: auto; | |
right: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment