Last active
November 7, 2018 02:21
-
-
Save noximus/ed2539c6898bc525c46541607d69d1fe to your computer and use it in GitHub Desktop.
Custom Styled Checkbox Input Form
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
<!DOCTYPE html> | |
<html> | |
<style> | |
/* The container */ | |
.container { | |
display: block; | |
position: relative; | |
padding-left: 35px; | |
margin-bottom: 12px; | |
cursor: pointer; | |
font-size: 22px; | |
-webkit-user-select: none; | |
-moz-user-select: none; | |
-ms-user-select: none; | |
user-select: none; | |
} | |
/* Hide the browser's default checkbox */ | |
.container input { | |
position: absolute; | |
opacity: 0; | |
cursor: pointer; | |
} | |
/* Create a custom checkbox */ | |
.checkmark { | |
position: absolute; | |
top: 0; | |
left: 0; | |
height: 25px; | |
width: 25px; | |
background-color: #eee; | |
border-radius: 50%; | |
} | |
/* On mouse-over, add a grey background color */ | |
.container:hover input ~ .checkmark { | |
background-color: #92929B; | |
} | |
/* When the checkbox is checked, add a blue background */ | |
.container input:checked ~ .checkmark { | |
background-color: white; | |
border: 1px solid #BFC3C5; | |
} | |
/* Create the checkmark/indicator (hidden when not checked) */ | |
.checkmark:after { | |
content: ""; | |
position: absolute; | |
display: none; | |
} | |
/* Show the checkmark when checked */ | |
.container input:checked ~ .checkmark:after { | |
display: block; | |
} | |
/* Style the indicator (dot/circle) */ | |
.container .checkmark:after { | |
top: 6px; | |
left: 6px; | |
width: 13px; | |
height: 13px; | |
border-radius: 50%; | |
background: #92929B; | |
} | |
</style> | |
<body> | |
<label class="container">One | |
<input type="checkbox" checked="checked"> | |
<span class="checkmark"></span> | |
</label> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment