Add files via upload

This commit is contained in:
Sam 2023-03-01 17:21:02 +03:00 committed by GitHub
parent 20e4d59ff0
commit c70f8aef35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<!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>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div>
<input type="checkbox" class="checkbox" id="checkbox">
<label for="checkbox" class="label">
<ion-icon class="moon" name="moon-outline"></ion-icon>
<ion-icon class="sun" name="sunny-outline"></ion-icon>
<div class="ball"></div>
</label>
</div>
<p>Light & Dark Theme Toggle with CSS and JavaScript By x39OME</p>
<script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
<script src="main.js"></script>
</body>
</html>

View File

@ -0,0 +1,5 @@
const checkbox = document.getElementById('checkbox');
checkbox.addEventListener('change', () => {
document.body.classList.toggle('dark');
});

View File

@ -0,0 +1,56 @@
*{
margin: 0;
padding:0;
box-sizing: border-box;
}
body{
background: #fff;
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 20px;
transition: background .3s linear;
}
body.dark{
background-color: #292c35;
}
body.dark p {
color: #fff;
}
.checkbox{
opacity: 0;
position: absolute;
}
.label{
background: #111;
display: flex;
align-items: center;
justify-content: space-between;
border-radius: 50px;
padding: 5px;
height: 26px;
width: 50px;
position: relative;
transform: scale(1.5);
}
.ball{
position: absolute;
top: 2px;
left: 2px;
background: #fff;
border-radius: 50%;
width: 22px;
height: 22px;
transition: .3s linear;
}
.checkbox:checked + .label .ball{
transform: translateX(24px);
}
.moon{
color: #f1c40f;
}
.sun{
color: #f39c12;
}