-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
128 lines (109 loc) · 3.25 KB
/
index.html
File metadata and controls
128 lines (109 loc) · 3.25 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GradientGenrator</title>
</head>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
body {
background-image: linear-gradient(to right top, #051937, #A8EB12);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 100vw;
flex-direction: column;
}
#btn1 {
height: 50px;
width: 170px;
color: white;
font-size: 14px;
background-color: #051937;
border: none;
border-radius: 50px;
box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
}
#btn2 {
height: 50px;
width: 170px;
color: white;
font-size: 14px;
background-color: #A8EB12;
border: none;
border-radius: 50px;
box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
}
.parent {
display: flex;
gap: 3rem;
}
h1 {
margin-top: 2rem;
color: white;
font-size: small;
text-decoration: underline;
}
.copyDiv {
margin-top: 30px;
height: 70px;
padding-top: 18px;
border-radius: 10px;
width: 350px;
border-left: 3px solid white;
text-align: center;
background-color: rgba(189, 189, 189, 0.4);
color: white;
}
</style>
<body>
<div class="parent">
<button id="btn1">#051937</button>
<button id="btn2">#A8EB12</button>
</div>
<h1>Copy your code:</h1>
<div class="copyDiv">
background-image: linear-gradient( to right top ,#051937,#A8EB12);
</div>
<script>
let btn1 = document.getElementById('btn1');
let btn2 = document.getElementById('btn2');
let copyDiv = document.querySelector('.copyDiv')
let rgb1 = '#051937'
let rgb2 = '#A8EB12'
const hexValue = () => {
let myHexaValue = "0123456789abcdef"
let color = "#"
for (let i = 0; i < 6; i++) {
color = color + myHexaValue[Math.floor(Math.random() * 16)]
}
return color;
}
const handleChange = () => {
rgb1 = hexValue();
btn1.innerText = rgb1
document.body.style.backgroundImage = `linear-gradient(to right top, ${rgb1}, ${rgb2})`
copyDiv.textContent = `background-image: linear-gradient( to right top ,${rgb1},${rgb2})`;
}
const handle_Change = () =>{
rgb2 = hexValue();
btn2.innerText = rgb2;
document.body.style.backgroundImage = `linear-gradient(to right top, ${rgb1}, ${rgb2})`
copyDiv.textContent = `background-image: linear-gradient( to right top ,${rgb1},${rgb2})`;
}
btn1.addEventListener('click', handleChange)
btn2.addEventListener('click', handle_Change)
copyDiv.addEventListener('click' ,()=>{
window.navigator.clipboard.writeText(copyDiv.textContent);
alert('Text copied To the clipBoard');
})
</script>
</body>
</html>