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>Day Night Toggle</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<input type="checkbox" id="day-night">
<label for="day-night" class="toggle-switch">
<span class="toggle-switch-handle">
<span class="crater crater-1"></span>
<span class="crater crater-2"></span>
<span class="crater crater-3"></span>
</span>
<span class="star star-1"></span>
<span class="star star-2"></span>
<span class="star star-3"></span>
<span class="star star-4"></span>
<span class="star star-5"></span>
<span class="star star-6"></span>
</label>
</div>
</body>
</html>
Below is the css code for this video.
style.css
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
width: 100%;
background-color: #b19cd9;
font-family: Arial, Helvetica, sans-serif;
overflow: hidden;
}
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 0 400px;
overflow: hidden;
}
.container input {
position: absolute;
left: -100%;
}
.toggle-switch {
position: relative;
display: inline-block;
height: 100px;
width: 180px;
background-color: #87ceeb;
border-radius: 168px;
cursor: pointer;
transition: all 0.25s cubic-bezier(0.5, 0.05, 0.5, 1);
}
.toggle-switch::before {
content: "AM";
position: absolute;
top: 30px;
left: -100px;
color: #87ceeb;
font-size: 36px;
letter-spacing: 2px;
text-shadow: 2px 2px 4px #0c1445;
transition: all 0.25s ease;
}
.toggle-switch::after {
content: "PM";
position: absolute;
top: 30px;
right: -100px;
color: #0c1445;
font-size: 36px;
letter-spacing: 4px;
text-shadow: none;
transition: all 0.25s ease;
}
.toggle-switch-handle {
position: relative;
top: 6px;
left: 6px;
display: inline-block;
height: 88px;
width: 88px;
background-color: #fdb813;
border-radius: 50%;
box-shadow: 0 4px 12px #808080;
transform: rotate(-45deg);
z-index: 1;
transition: all 0.5s cubic-bezier(0.67, -0.5, 0.25, 1.5);
}
.toggle-switch-handle .crater {
position: absolute;
background-color: #80848f;
border-radius: 50%;
opacity: 0;
transition: opacity 0.25s ease-in-out;
}
.toggle-switch-handle .crater-1 {
top: 36px;
left: 20px;
height: 8px;
width: 8px;
}
.toggle-switch-handle .crater-2 {
top: 56px;
left: 44px;
height: 12px;
width: 12px;
}
.toggle-switch-handle .crater-3 {
top: 20px;
left: 50px;
height: 16px;
width: 16px;
}
.star {
position: absolute;
background-color: #f3eee1;
border-radius: 50%;
transition: all 0.5s cubic-bezier(0.5, 0.05, 0.5, 1);
}
.star-1 {
top: 20px;
left: 70px;
height: 6px;
width: 60px;
z-index: 0;
}
.star-2 {
top: 36px;
left: 56px;
height: 6px;
width: 60px;
z-index: 1;
}
.star-3 {
top: 54px;
left: 80px;
height: 6px;
width: 60px;
z-index: 0;
}
.star-4, .star-5, .star-6 {
transform: translate(6px, 0);
z-index: 0;
opacity: 0;
transition: all 0.5s cubic-bezier(0.5, 0.05, 0.5, 1);
}
.star-4 {
top: 32px;
left: 22px;
height: 4px;
width: 4px;
}
.star-5 {
top: 64px;
left: 34px;
height: 6px;
width: 6px;
}
.star-6 {
top: 72px;
left: 56px;
height: 4px;
width: 4px;
}
input:checked+.toggle-switch {
background-color: #0c1445;
}
input:checked+.toggle-switch::before {
color: #87ceeb;
letter-spacing: 4px;
text-shadow: none;
transition: all 0.25s ease;
}
input:checked+.toggle-switch::after {
color: #0c1445;
letter-spacing: 2px;
text-shadow: 2px 2px 4px #87ceeb;
transition: all 0.25s ease;
}
input:checked+.toggle-switch .toggle-switch-handle {
background-color: #f6f1d5;
transform: translate(80px, 0) rotate(0deg);
}
input:checked+.toggle-switch .toggle-switch-handle .crater {
opacity: 1;
}
input:checked+.toggle-switch .star-1 {
height: 4px;
width: 4px;
}
input:checked+.toggle-switch .star-2 {
height: 8px;
width: 8px;
transform: translate(-10px, 0);
}
input:checked+.toggle-switch .star-3 {
height: 4px;
width: 4px;
transform: translate(-14px, 0);
}
input:checked+.toggle-switch .star-4, input:checked+.toggle-switch .star-5, input:checked+.toggle-switch .star-6 {
transform: translate(0, 0);
opacity: 1;
transition: all 0.5s 0.25s cubic-bezier(0.5, 0.05, 0.5, 1);
}
Thanks for visiting