Skip to content

Commit b1cbc16

Browse files
BASE FILE UPLOADED FROM LOCALHOST
THESE ARE THE FILES OF BUTTON THAT SWITCHES PAGE FROM WHICH THE PAGE COLOR CHANGES FROM LIGHT TO DARK AND VISA VERSA
1 parent be8cb70 commit b1cbc16

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

DarkMode/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>DarkMode</title>
8+
<link rel="stylesheet" href="style.css" />
9+
<link rel="stylesheet" href="mediaqueries.css" />
10+
</head>
11+
<body>
12+
<div class="container">
13+
<button id="mode-toggle">Dark Mode</button>
14+
</div>
15+
</footer>
16+
<script src="script.js"></script>
17+
</body>
18+
</html>

DarkMode/script.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const modeToggle = document.getElementById('mode-toggle');
2+
const body = document.body;
3+
4+
modeToggle.addEventListener('click', () => {
5+
body.classList.toggle('dark-mode');
6+
7+
if (body.classList.contains('dark-mode')) {
8+
modeToggle.textContent = 'Switch to Light Mode';
9+
} else {
10+
modeToggle.textContent = 'Switch to Dark Mode';
11+
}
12+
});

DarkMode/style.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
:root {
3+
--background-color: white;
4+
--text-color: black;
5+
}
6+
7+
body {
8+
background-color: var(--background-color);
9+
color: var(--text-color);
10+
transition: background-color 0.3s, color 0.3s;
11+
}
12+
13+
.dark-mode {
14+
--background-color: black;
15+
--text-color: white;
16+
}
17+
18+
.container {
19+
max-width: 800px;
20+
margin: 0 auto;
21+
padding: 20px;
22+
}
23+
24+
#mode-toggle {
25+
padding: 10px 20px;
26+
cursor: pointer;
27+
}
28+

0 commit comments

Comments
 (0)