In this #tutorial , we'll guide you through the process of creating a stylish #dark and #light Mode #toggle Button #foryourwebsite. Dark mode is not only visually appealing but also helps reduce eye strain in low-light conditions. We'll show you step by step how to implement this feature, making your website more user-friendly. By the end of this video, you'll have a fully functional Dark and Light Mode Toggle Button that enhances your website's user experience.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Dark Light Mode</title>
</head>
<body>
<div>
<input type="checkbox" class="checkbox">
</div>
</body>
</html>
style.css
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
display: grid;
height: 100vh;
place-items: center;
background-color: black;
}
.checkbox{
height: 200px;
background-color: rgb(149,124,124);
border-radius: 100px;
width: 400px;
appearance: none;
box-shadow: inset 0 10px 20px rgba(0,0,0,0.5),
inset 0 10px 16px rgba(0,0,0,0.5),
inset 0 -5px 20px rgba(0,0,0,0.5);
outline: none;
cursor: pointer;
position: relative;
transition: 0.5s;
background-image: url(Image/nightsky.jpeg);
background-size: cover;
}
.checkbox::before{
height: 150px;
width: 150px;
position: absolute;
top: 25px;
left: 25px;
content: '';
background-color: linear-gradient(to bottom, black, black);
border-radius: 50%;
transition: 0.5s;
box-shadow: 0 8px 40px rgba(0,0,0,0.5),
inset 4px 4px rgba(255,255,255,0.2),
inset -4px 4px rgba(255,255,255,0.2);
background-image: url(Image/sun.svg);
background-size: cover;
}
.checkbox:checked{
background-color: #fff;
box-shadow: inset 0 20px 60px rgba(0,0,0,0.1),
inset 0 2px 8px rgba(0,0,0,0.1),
inset 0 4px 4px rgba(0,0,0,0.05);
background-image: url(Image/sunshine.jpg);
background-size: cover;
}
.checkbox:checked::before{
left: 225px;
box-shadow: 0 8px 20px rgba(0,0,0,0.1),
inset 4px 4px rgba(255,255,255,0.5),
inset -4px 4px rgba(255,255,255,0.5);
background-color: linear-gradient(to bottom white , white);
background-image: url(Image/moon.svg);
background-size: cover;
}
.checkbox::after{
content: '';
position: absolute;
height: 110vh;
width: 100rem;
background: black;
top: 80px;
left: 190px;
z-index: -1;
transform: translate(-50%, -50%);
transition: 0.5s;
}
.checkbox:checked::after{
background: white;
}
Comments
Post a Comment