Add files via upload
This commit is contained in:
parent
20e4d59ff0
commit
c70f8aef35
25
100_projects/8-light-&-dark-theme-toggle/inedx.html
Normal file
25
100_projects/8-light-&-dark-theme-toggle/inedx.html
Normal 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>
|
5
100_projects/8-light-&-dark-theme-toggle/main.js
Normal file
5
100_projects/8-light-&-dark-theme-toggle/main.js
Normal file
@ -0,0 +1,5 @@
|
||||
const checkbox = document.getElementById('checkbox');
|
||||
|
||||
checkbox.addEventListener('change', () => {
|
||||
document.body.classList.toggle('dark');
|
||||
});
|
56
100_projects/8-light-&-dark-theme-toggle/style.css
Normal file
56
100_projects/8-light-&-dark-theme-toggle/style.css
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user