Back
A thorough exploration of building a tactile, floating button that reacts to hovering with a mesmerizing lift and glow effect.
<div class="levitation-container"> <button class="levitation-button"> <span>Hover Me!</span> </button> </div>
.levitation-container { display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(145deg, #e6e7ee, #ffffff); }Now, let's focus on the button itself. The levitation effect is achieved through smooth transitions and shadows that create depth, achieving a floating effect.
.levitation-button { font-size: 16px; padding: 15px 30px; border: none; border-radius: 12px; background: linear-gradient(145deg, #f0f0f3, #c8c8c8); box-shadow: 8px 8px 15px #d1d9e6, -8px -8px 15px #ffffff; color: #31344b; cursor: pointer; transition: all 0.3s ease-in-out; }When the user hovers over the button, CSS transitions and shadow adjustments will come into play, elevating the button visually as if it's floating above the surface, responding with touch-like precision.
.levitation-button:hover { transform: translateY(-10px); box-shadow: 15px 15px 30px #d1d9e6, -15px -15px 30px #ffffff; }With these simple yet magical steps, you can instantly add an engaging hover effect to your buttons, enhancing your user's interactive experience.
<div class="levitation-container"> <button class="levitation-button"> <span>Hover Me!</span> </button> </div> <style> .levitation-container { display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(145deg, #e6e7ee, #ffffff); } .levitation-button { font-size: 16px; padding: 15px 30px; border: none; border-radius: 12px; background: linear-gradient(145deg, #f0f0f3, #c8c8c8); box-shadow: 8px 8px 15px #d1d9e6, -8px -8px 15px #ffffff; color: #31344b; cursor: pointer; transition: all 0.3s ease-in-out; } .levitation-button:hover { transform: translateY(-10px); box-shadow: 15px 15px 30px #d1d9e6, -15px -15px 30px #ffffff; } </style>Thank you for reading this article.
Comments
No comments yet. Be the first to comment!