Skip to content

Instantly share code, notes, and snippets.

@sdhagen
Created April 22, 2021 23:30
Show Gist options
  • Save sdhagen/8755df325744df13199fbd31e4616993 to your computer and use it in GitHub Desktop.
Save sdhagen/8755df325744df13199fbd31e4616993 to your computer and use it in GitHub Desktop.
Black Checkbox Toggles (Basic CSS)
<div class="center">
<h1> 1 </h1>
<input type="checkbox" name="">
<h1> 2 </h1>
<input type="checkbox" name="">
<h1> 3 </h1>
<input type="checkbox" name="">
<h1> 4 </h1>
<input type="checkbox" name="">
</div>
/*
More Exciting than a boring Checkbox
*/
body {
margin: 0;
padding: 0;
background: #151515;
}
.center {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
input[type="checkbox"] {
margin: 10px;
position: relative;
width: 120px;
height: 40px;
-webkit-appearance: none;
background: linear-gradient(0deg, #333, #000);
outline: none;
border-radius: 20px;
box-shadow: 0 0 0 4px #353535, 0 0 0 5px #3e3e3e,
inset 0 0 10px rgba(0, 0, 0, 1);
}
input:checked[type="checkbox"]:nth-of-type(1) {
background: linear-gradient(0deg, #7f00ff, #e100ff);
box-shadow: 0 0 0 4px #353535, 0 0 0 5px #3e3e3e,
inset 0 0 10px rgba(0, 0, 0, 1);
}
input:checked[type="checkbox"]:nth-of-type(2) {
background: linear-gradient(0deg, #1488cc, #2b32b2);
box-shadow: 0 0 0 4px #353535, 0 0 0 5px #3e3e3e,
inset 0 0 10px rgba(0, 0, 0, 1);
}
input:checked[type="checkbox"]:nth-of-type(3) {
background: linear-gradient(0deg, #f8ff00, #3ad59f);
box-shadow: 0 0 0 4px #353535, 0 0 0 5px #3e3e3e,
inset 0 0 10px rgba(0, 0, 0, 1);
}
input:checked[type="checkbox"]:nth-of-type(4) {
background: linear-gradient(0deg, #f12711, #f5af19);
box-shadow: 0 0 0 4px #353535, 0 0 0 5px #3e3e3e,
inset 0 0 10px rgba(0, 0, 0, 1);
}
input[type="checkbox"]:before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 80px;
height: 40px;
background: linear-gradient(0deg, #000, #6b6b6b);
border-radius: 20px;
box-shadow: 0 0 0 1px #232323;
transform: scale(0.98, 0.96);
transition: 0.5s;
}
input:checked[type="checkbox"]:before {
left: 40px;
}
input[type="checkbox"]:after {
content: "";
position: absolute;
top: calc(50% - 2px);
left: 70px;
width: 4px;
height: 4px;
background: linear-gradient(0deg, #6b6b6b, #000);
border-radius: 50%;
transition: 0.5s;
}
input:checked[type="checkbox"]:after {
left: 110px;
}
h1 {
margin: 0;
padding: 0;
font-family: sans-serif;
text-align: center;
color: #fff;
font-size: 16px;
padding: 15px 0;
text-transform: uppercase;
letter-spacing: 4px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment