-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomcolorselector.html
More file actions
61 lines (57 loc) · 1.07 KB
/
Copy pathRandomcolorselector.html
File metadata and controls
61 lines (57 loc) · 1.07 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
<html>
<head>
<title>Random Color Selector</title>
<style>
* {
margin: 0;
padding: 0;
font-family: 'Quicksand', sans-serif;
}
body{
background: #000000;
}
.main{
width: 350px;
height: 250px;
background: white;
position: absolute;
top:50%;
left: 50%;
transform: translate(-50%,-50%);
display: flex;
justify-content: center;
flex-direction: column;
}
#text{
font-size: 3rem;
margin-bottom: 20px;
}
.generateBtn{
padding: 10px 20px;
font-size: 1.1rem;
border: none;
outline: none;
cursor: pointer;
background: #1687a7;
color: white;
}
</style>
</head>
<body>
<div class="main">
<div id="text">#000000</div>
<button onclick="generateColor()" class="generateBtn">
GENERATE COLOR
</button>
</div>
<script>
function generateColor() {
var randomColor= (Math.floor(Math.random()*16777216)).toString(16);
console.log(randomColor)
document.body.style.backgroundColor = "#" + randomColor;
var text = document.getElementById("text");
text.innerText = "#" + randomColor;
}
</script>
</body>
</html>