-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathindex.html
82 lines (72 loc) · 2.48 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Gradient Generator</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #f4f4f4;
}
h1 {
margin-bottom: 20px;
}
.gradient-box {
width: 300px;
height: 300px;
border-radius: 10px;
margin-bottom: 20px;
background: transparent; /* Start with transparent */
transition: background 0.5s ease;
border: 2px dashed #ccc; /* Optional border */
}
.gradient-box:hover {
/* Show gradient on hover */
background: linear-gradient(90deg, #ff0000, #0000ff); /* Default gradient */
}
input[type="color"] {
margin: 10px;
width: 100px;
height: 40px;
border: none;
border-radius: 5px;
}
#css-code {
margin-top: 10px;
font-family: monospace;
background-color: #fff;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
width: 300px;
text-align: center;
}
</style>
</head>
<body>
<h1>CSS Gradient Generator</h1>
<div class="gradient-box" id="gradientBox"></div>
<input type="color" id="color1" value="#ff0000" onchange="updateGradient()">
<input type="color" id="color2" value="#0000ff" onchange="updateGradient()">
<div id="css-code">background: linear-gradient(90deg, #ff0000, #0000ff);</div>
<script>
function updateGradient() {
const color1 = document.getElementById('color1').value;
const color2 = document.getElementById('color2').value;
const gradientBox = document.getElementById('gradientBox');
const cssCode = document.getElementById('css-code');
const gradient = `linear-gradient(90deg, ${color1}, ${color2})`;
gradientBox.style.background = gradient; // Update background on hover
cssCode.textContent = `background: ${gradient};`;
}
// Set the default gradient on load
window.onload = updateGradient;
</script>
</body>
</html>