JSFiddle - React, Tailwind, and code Playground
by Prathameshsb
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animated Gradient Object</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="hero">
<div class="abstract-object"></div>
<div class="glass-effect">
<h1>Welcome to My Website</h1>
</div>
</div>
</body>
</html>
CSS
/* Base styling */
body, html {
margin: 0;
padding: 0;
height: 100%;
}
.hero {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
position: relative;
background: #000; /* Optional: Change to your preference */
}
.abstract-object {
width: 300px;
height: 300px;
border-radius: 50%; /* Makes it circular */
background: linear-gradient(45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
background-size: 400% 400%;
animation: gradientBG 15s ease infinite, rotate 20s linear infinite;
position: absolute;
}
@keyframes gradientBG {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
@keyframes rotate {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.glass-effect {
background: rgba(255, 255, 255, 0.1);
border-radius: 10px;
padding: 20px;
backdrop-filter: blur(5px);
border: 1px solid rgba(255, 255, 255, 0.18);
z-index: 1; /* Ensures the text appears above the abstract object */
position: relative;
}
h1 {
color: white;
text-align: center;
}