Last active
December 22, 2015 22:18
-
-
Save eikaramba/6538768 to your computer and use it in GitHub Desktop.
Clear nice Custom checkbox
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
$ccb_height: 30px; | |
$ccb_width: 70px; | |
$ccb_slider_width: 22px; | |
$ccb_color_false:#F7836D; | |
$ccb_color_true:#80b50d; | |
input[type="checkbox"].custom-checkbox { | |
display: none; | |
} | |
.custom-checkbox { | |
//background false state | |
+ label { | |
background-color: #fff; | |
border-radius: 7px; | |
display: inline-block; | |
position: relative; | |
background: $ccb_color_false; | |
width: $ccb_width; | |
height: $ccb_height; | |
@include box-shadow(inset 0 0 20px rgba(0, 0, 0, 0.1)); | |
&:before,&:after { | |
@include transition(all 0.1s ease-in); | |
font-size: 14px; | |
position: absolute; | |
color: #fff; | |
display:block; | |
} | |
//slider | |
&:before { | |
position: absolute; | |
content: ''; | |
background: #fff; | |
top: 0; | |
left: 0; | |
width: $ccb_slider_width; | |
height: $ccb_height; | |
border-radius: 7px; | |
@include box-shadow(0 0 1px rgba(0,0,0,0.6)); | |
} | |
//label default:false | |
&:after { | |
content: 'NO'; | |
top: 0; | |
right: 6px; | |
font-weight: bold; | |
line-height:$ccb_height; | |
vertical-align:middle; | |
border-radius: 100px; | |
} | |
} | |
//true state | |
&:checked { | |
+ label { | |
background: $ccb_color_true; | |
&:before { left: $ccb_width - $ccb_slider_width; } | |
//label true | |
&:after { | |
content: 'YES'; | |
left: 6px; | |
} | |
} | |
} | |
} |
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
<input class="custom-checkbox" id="myCoolCheckbox" type="checkbox"> | |
<label for="myCoolCheckbox"></label> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this uses compass and scss, don't forget to include them in your scss files!