The content on this website, including videos and code examples, is for educational purposes only. All demonstrations and designs are fictional and created to illustrate coding techniques. Any resemblance to existing websites or brands is purely coincidental.
The creators and administrators of this website do not claim ownership or affiliation with any existing websites or companies. Users are encouraged to use the information responsibly for learning purposes. Liability for any misuse of the content provided is not accepted.
Below is the html code for this video.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom Checkboxes</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Custom Checkboxes</h1>
<ul class="list">
<li class="list-item">
<h5>iOS Style</h5>
<input type="checkbox" id="check1" class="input-check ios-style-input">
<label for="check1" class="btn-check"></label>
</li>
<li class="list-item">
<h5>Skewed Style</h5>
<input type="checkbox" id="check2" class="input-check skewed-style-input">
<label for="check2" class="btn-check" attr-no="NO" attr-yes="YES"></label>
</li>
<li class="list-item">
<h5>Flipping Style</h5>
<input type="checkbox" id="check3" class="input-check flipping-style-input">
<label for="check3" class="btn-check" attr-no="No" attr-yes="Yes"></label>
</li>
</ul>
</body>
</html>
Below is the css code for this video.
style.css
*, *::after, *::before {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
width: 100%;
background: #0f4d92;
color: #b0e0e6;
font-family: sans-serif;
}
h1 {
position: absolute;
top: 25%;
transform: translateY(-25%);
width: 100%;
text-align: center;
font-size: 72px;
font-family: fantasy;
}
ul, li {
list-style: none;
}
.list {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
justify-content: center;
}
.list-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: max-content;
margin: 0 30px;
}
h5 {
font-family: monospace;
font-size: x-large;
letter-spacing: 1px;
margin-bottom: 15px;
}
.input-check {
display: none;
}
.input-check::selection, .input-check::after::selection, .input-check::before::selection, .input-check *::selection,
.input-check *::after::selection, .input-check *::before::selection, .input-check+.btn-check::selection {
background: none;
}
.input-check+.btn-check {
position: relative;
display: block;
height: 32px;
width: 64px;
outline: none;
cursor: pointer;
user-select: none;
}
.input-check+.btn-check::after, .input-check+.btn-check::before {
content: "";
position: relative;
display: block;
height: 100%;
width: 50%;
}
.input-check+.btn-check::after {
left: 0;
}
.input-check+.btn-check::before {
display: none;
}
.input-check:checked+.btn-check::after {
left: 50%;
}
.ios-style-input+.btn-check {
background: #8c92ac;
border-radius: 32px;
padding: 2px;
transition: all 0.5s ease;
}
.ios-style-input+.btn-check::after {
background: #ffffff;
border-radius: 32px;
box-shadow: 0 0 0 1px #0000001a, 0 4px 0 #0000000d;
transition: left 0.5s cubic-bezier(0.25, 0.75, 0.33, 1.25), padding 0.5s ease, margin 0.5s ease;
}
.ios-style-input+.btn-check:hover::after {
will-change: padding;
}
.ios-style-input+.btn-check:active {
box-shadow: inset 0 0 0 32px #8c92ac;
}
.ios-style-input+.btn-check:active::after {
padding-right: 12px;
}
.ios-style-input:checked+.btn-check {
background: #40826d;
}
.ios-style-input:checked+.btn-check:active {
box-shadow: none;
}
.ios-style-input:checked+.btn-check:active::after {
margin-left: -12px;
}
.skewed-style-input+.btn-check {
background: #8c92ac;
transform: skew(-15deg);
backface-visibility: hidden;
overflow: hidden;
transition: all 0.25s ease;
}
.skewed-style-input+.btn-check::after, .skewed-style-input+.btn-check::before {
position: absolute;
display: inline-block;
width: 100%;
color: #ffffff;
transform: skew(15deg);
text-align: center;
line-height: 32px;
font-weight: bold;
text-shadow: 0 1px 0 #00000080;
transition: all 0.25s ease;
}
.skewed-style-input+.btn-check::after {
content: attr(attr-yes);
top: 100%;
}
.skewed-style-input+.btn-check::before {
content: attr(attr-no);
top: 0;
left: 0;
}
.skewed-style-input+.btn-check:active {
background: #8c92ac;
}
.skewed-style-input+.btn-check:active::before {
top: -10%;
}
.skewed-style-input:checked+.btn-check {
background: #40826d;
}
.skewed-style-input:checked+.btn-check::before {
top: -100%;
}
.skewed-style-input:checked+.btn-check::after {
top: 0;
left: 0;
}
.skewed-style-input:checked+.btn-check:active::after {
top: 10%;
}
.flipping-style-input+.btn-check {
padding: 2px;
perspective: 100px;
transition: all 0.25s ease;
}
.flipping-style-input+.btn-check::after, .flipping-style-input+.btn-check::before {
position: absolute;
top: 0;
left: 0;
display: inline-block;
width: 100%;
color: #ffffff;
text-align: center;
border-radius: 4px;
line-height: 32px;
font-weight: bold;
backface-visibility: hidden;
transition: all 0.5s ease;
}
.flipping-style-input+.btn-check::after {
content: attr(attr-yes);
background: #40826d;
transform: rotateX(-180deg);
}
.flipping-style-input+.btn-check::before {
content: attr(attr-no);
background: #cf352e;
}
.flipping-style-input+.btn-check:active::before {
transform: rotateX(-20deg);
}
.flipping-style-input:checked+.btn-check::before {
transform: rotateX(180deg);
}
.flipping-style-input:checked+.btn-check::after {
left: 0;
transform: rotateX(0deg);
background: #40826d;
}
.flipping-style-input:checked+.btn-check:active::after {
transform: rotateX(20deg);
}
Thanks for visiting