<script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script> <script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script> <div class="gradient-background"></div> <div class="content-card"> <div class="icon-container"> <ion-icon name="color-palette-outline"></ion-icon> </div> <h1>Animated Gradient Background</h1> <p>Experience smooth, professional gradient transitions with CSS animations. Perfect for modern web applications.</p> <button class="btn" onclick="changeGradient()"> Change Animation Speed </button> <div class="info-text"> <ion-icon name="information-circle-outline"></ion-icon> <span>Using color #aceca1</span> </div> </div>
* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; height: 100vh; display: flex; justify-content: center; align-items: center; overflow: hidden; position: relative; } .gradient-background { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(45deg, #aceca1, #7fd87f, #aceca1, #5fc95f); background-size: 400% 400%; animation: gradientShift 15s ease infinite; z-index: -1; } @keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } .content-card { background: rgba(255, 255, 255, 0.95); padding: 3rem 2.5rem; border-radius: 16px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); text-align: center; max-width: 500px; backdrop-filter: blur(10px); } .icon-container { font-size: 4rem; color: #aceca1; margin-bottom: 1.5rem; animation: float 3s ease-in-out infinite; } @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } } h1 { color: #2c3e50; font-size: 2rem; margin-bottom: 1rem; font-weight: 600; } p { color: #546e7a; font-size: 1rem; line-height: 1.6; margin-bottom: 2rem; } .btn { background: linear-gradient(135deg, #aceca1, #7fd87f); color: white; border: none; padding: 0.875rem 2rem; border-radius: 8px; font-size: 1rem; font-weight: 500; cursor: pointer; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(172, 236, 161, 0.3); } .btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(172, 236, 161, 0.4); } .btn:active { transform: translateY(0); } .info-text { margin-top: 2rem; font-size: 0.875rem; color: #78909c; display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
let speed = 15; const gradientBg = document.querySelector('.gradient-background'); function changeGradient() { speed = speed === 15 ? 8 : speed === 8 ? 25 : 15; gradientBg.style.animation = `gradientShift ${speed}s ease infinite`; const btn = document.querySelector('.btn'); btn.textContent = speed === 15 ? 'Change Animation Speed' : speed === 8 ? 'Speed: Fast ⚡' : 'Speed: Slow 🐌'; }
Login to leave a comment
No comments yet. Be the first!
View Project
No comments yet. Be the first!