-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomBackgroundColorGenerator.html
More file actions
84 lines (75 loc) · 2.09 KB
/
Copy pathRandomBackgroundColorGenerator.html
File metadata and controls
84 lines (75 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Color Flipper</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: system-ui, sans-serif;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #22c55e;
transition: background 0.3s ease;
}
.box {
background: white;
padding: 35px;
border-radius: 20px;
text-align: center;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}
h2 {
font-size: 16px;
text-transform: uppercase;
letter-spacing: 1px;
color: #64748b;
margin-bottom: 10px;
}
h1 {
font-family: monospace;
color: #0f172a;
margin-bottom: 25px;
font-size: 32px;
}
button {
padding: 14px 24px;
background: #0f172a;
color: white;
border: none;
border-radius: 12px;
font-weight: 600;
cursor: pointer;
transition: transform 0.1s;
}
button:active {
transform: scale(0.98);
}
</style>
</head>
<body>
<div class="box">
<h2>Background Color</h2>
<h1 id="colorCode">#22c55e</h1>
<button onclick="changeColor()">Flip Color</button>
</div>
<script>
function changeColor() {
const hex = "0123456789ABCDEF";
let color = "#";
for (let i = 0; i < 6; i++) {
color += hex[Math.floor(Math.random() * 16)];
}
document.body.style.background = color;
document.getElementById("colorCode").innerText = color;
}
</script>
</body>
</html>