-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
animated-rainbow-border.html
146 lines (134 loc) · 2.95 KB
/
animated-rainbow-border.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html>
<head>
<style>
body {
display: flex;
flex-direction: column;
gap: 20px;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background: #1a1a1a;
}
.rainbow-box {
position: relative;
width: 300px;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
background: #2a2a2a;
border-radius: 10px;
}
.rainbow-box::before {
content: '';
position: absolute;
top: -3px;
left: -3px;
right: -3px;
bottom: -3px;
background: linear-gradient(
45deg,
#ff0000,
#ff8000,
#ffff00,
#00ff00,
#00ffff,
#0000ff,
#8000ff,
#ff0080,
#ff0000
);
background-size: 200% 200%;
border-radius: 12px;
z-index: -1;
filter: blur(6px);
opacity: 0;
transform: scale(0.95);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.rainbow-box.animated::before {
opacity: 1;
transform: scale(1);
animation: gradient 1.5s ease infinite,
pulse 2s ease-in-out infinite;
}
.rainbow-box::after {
content: '';
position: absolute;
inset: 2px;
background: #2a2a2a;
border-radius: 8px;
z-index: 0;
}
.content {
color: white;
font-family: system-ui, sans-serif;
font-size: 24px;
text-align: center;
position: relative;
z-index: 1;
}
.toggle-button {
padding: 12px 24px;
font-size: 16px;
color: white;
background: #444;
border: none;
border-radius: 6px;
cursor: pointer;
transition: all 0.3s ease;
}
.toggle-button:hover {
background: #555;
transform: translateY(-2px);
}
.toggle-button:active {
background: #333;
transform: translateY(0px);
}
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
@keyframes pulse {
0% {
opacity: 1;
filter: blur(6px) brightness(1.2);
}
50% {
opacity: 0.8;
filter: blur(5px) brightness(1);
}
100% {
opacity: 1;
filter: blur(6px) brightness(1.2);
}
}
</style>
</head>
<body>
<div class="rainbow-box">
<div class="content">Rainbow Border</div>
</div>
<button class="toggle-button" onclick="toggleAnimation()">Start Animation</button>
<script>
function toggleAnimation() {
const box = document.querySelector('.rainbow-box');
const button = document.querySelector('.toggle-button');
box.classList.toggle('animated');
button.textContent = box.classList.contains('animated') ?
'Stop Animation' : 'Start Animation';
}
</script>
</body>
</html>