-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
84 lines (72 loc) · 1.75 KB
/
index.html
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
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width",initial-scale=1.0>
<title>Document</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap');
*{
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: 'Roboto' , sans-serif;
}
body{
transition: 0.5s;
/* background-color: black; */
}
.main{
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.container{
width:30rem;
/* height: 15rem; */
padding: 10px;
border-radius: 10px;
font-size: 40px;
background-color: white;
text-align: center;
}
button{
margin-top: 5px;
width: 100%;
background-color: black;
color: white;
border: none;
border-radius: 5px;
display: block;
font-size: 35px;
}
</style>
</head>
<body>
<div class="main">
<div class="container">
<h2 id="color-code"> #fff</h2>
<button id="btn">Click Me</button>
</div>
</div>
<script>const getcolor = () => {
//hex code
const randomNumnber =Math.floor( Math.random()*16777215 );
const randomcode = "#" + randomNumnber.toString(16);
document.body.style.backgroundColor = randomcode;
console.log(randomNumnber,randomcode);
document.getElementById("color-code").innerText=randomcode;
navigator.clipboard.writeText(randomcode);
}
// event call
document.getElementById("btn").addEventListener(
"click",
getcolor
)
// initial call
getcolor();
</script>
</body>
</html>