-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
64 lines (63 loc) · 1.77 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="pic.png"/>
<title>Color Picker</title>
<style>
body{
text-align: center;
background-color: aliceblue;
}
.box{
border: 1px solid skyblue;
border-radius: 10px;
width: 400px;
height: 200px;
margin: auto;
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
}
button:hover{
color: blue;
}
@media (max-width:408px) {
div{
width: 250px;
}
}
@media (max-width:310px) {
div{
width:150px;
}
}
</style>
</head>
<body>
<h4>Random Color Generator</h4>
<img src="pic.png" width="50px" height="50px">
<br><br>
<button>Generate Color</button>
<br>
<br>
<div class="box"></div>
<script>
let btn=document.querySelector("button");
btn.addEventListener("click",function(){
let h4=document.querySelector("h4");
let randomcolor =getRandomcolor();
h4.innerText=randomcolor;
let div=document.querySelector("div");
div.style.backgroundColor=randomcolor;
console.log("Color , Updated");
});
function getRandomcolor(){
let red=Math.floor(Math.random()*255);
let green=Math.floor(Math.random()*255);
let blue=Math.floor(Math.random()*255);
let color=`rgb(${red},${green},${blue})`;
return color;
}
</script>
</body>
</html>