Skip to content

Commit 4720d51

Browse files
authored
Add files via upload
1 parent 3405536 commit 4720d51

3 files changed

Lines changed: 67 additions & 1 deletion

File tree

index.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
<!-- placeholder file -->
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Just Practice</title>
8+
<link rel="stylesheet" href="style.css">
9+
</head>
10+
11+
<body>
12+
<div class="container">
13+
<h1>Click the button to change the background color</h1>
14+
<p id="colorCode"></p>
15+
<button id="colorBtn">Click Here</button>
16+
</div>
17+
<script src="script.js"></script>
18+
</body>
19+
20+
</html>

script.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const colorBtn = document.getElementById("colorBtn");
2+
3+
function getRandomColor() {
4+
const random = "#" + Math.floor(Math.random() * 16777215).toString(16);
5+
return random;
6+
}
7+
8+
colorBtn.addEventListener("click", () => {
9+
const color = getRandomColor();
10+
document.body.style.backgroundColor = color;
11+
document.getElementById("colorCode").textContent = `Current Color: ${color}`;
12+
});

style.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
body {
2+
font-family: sans-serif;
3+
text-align: center;
4+
padding: 50px 20px;
5+
transition: background-color 0.3s ease;
6+
}
7+
8+
.container {
9+
border: 5px solid black;
10+
border-radius: 50px;
11+
height: 200px;
12+
width: 25%;
13+
margin: auto;
14+
background-color: white;
15+
}
16+
17+
h1 {
18+
margin-top: 30px;
19+
}
20+
21+
button {
22+
font-size: 20px;
23+
padding: 10px 30px;
24+
font-weight: 600;
25+
border: none;
26+
border-radius: 30px;
27+
background-color: crimson;
28+
color: white;
29+
cursor: pointer;
30+
}
31+
32+
p {
33+
font-size: 15px;
34+
color: cornflowerblue;
35+
}

0 commit comments

Comments
 (0)