-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | ||
<title>Ultimate Background color changer</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
<body style="background-color: #212121; color: #fff"> | ||
<nav> | ||
<a href="/" aria-current="page">Home</a> | ||
<a target="_blank" href="https://www.youtube.com/@channel" | ||
>Channel Name</a | ||
> | ||
</nav> | ||
|
||
<h1>Start should change the Background color every second</h1> | ||
<button id="start">Start</button> | ||
<button id="stop">Stop</button> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//generate a random color | ||
|
||
const randomColor = function () { | ||
const hex = '0123456789ABCDEF'; | ||
let color = '#'; | ||
for (let i = 0; i < 6; i++) { | ||
color += hex[Math.floor(Math.random() * 16)]; | ||
} | ||
return color; | ||
}; | ||
|
||
let intervalId; | ||
const startChangingColor = function () { | ||
if (!intervalId) { | ||
intervalId = setInterval(changeBgColor, 1000); | ||
} | ||
|
||
function changeBgColor() { | ||
document.body.style.backgroundColor = randomColor(); | ||
} | ||
}; | ||
const stopChangingColor = function () { | ||
clearInterval(intervalId); | ||
intervalId = null; | ||
}; | ||
|
||
document.querySelector('#start').addEventListener('click', startChangingColor); | ||
|
||
document.querySelector('#stop').addEventListener('click', stopChangingColor); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
font-family: system-ui, sans-serif; | ||
color: black; | ||
background-color: white; | ||
} | ||
|
||
nav { | ||
display: flex; | ||
flex-wrap: wrap; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 0.5rem; | ||
gap: 0.5rem; | ||
border-bottom: solid 1px #aaa; | ||
background-color: #eee; | ||
} | ||
|
||
nav a { | ||
display: inline-block; | ||
min-width: 9rem; | ||
padding: 0.5rem; | ||
border-radius: 0.2rem; | ||
border: solid 1px rgb(22, 22, 22); | ||
text-align: center; | ||
text-decoration: none; | ||
color: #1b1b1b; | ||
} | ||
|
||
nav a[aria-current='page'] { | ||
color: #000; | ||
background-color: #d4d4d4; | ||
} | ||
|
||
main { | ||
padding: 1rem; | ||
} | ||
|
||
h1 { | ||
font-weight: bold; | ||
font-size: 1.5rem; | ||
} | ||
|
||
.projects { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.project-link { | ||
background-color: #fff; | ||
padding: 10px 30px; | ||
border-radius: 8px; | ||
color: #212121; | ||
text-decoration: none; | ||
border: 2px solid #212121; | ||
margin-top: 5px; | ||
} |