Back
Learn how to create an eye-catching 3D button with a satisfying click animation using only HTML and CSS.
<button class="button-3d">CLICK</button>
.button-3d { border: none; background-color: #976D70; color: #fff; padding: 10px 20px; transition: 0.2s; border-radius: 6px; box-shadow: #665367 0 7px 2px, #000 0 8px 6px; cursor: pointer; }The real interactive magic happens when the button is pressed. We use the :active pseudo-class to detect when the user clicks the button. When pressed, we transform the button by moving it downward 8px along the Y-axis, precisely matching the distance of our shadow effect. Simultaneously, we adjust the box-shadow property to remove the height shadow completely and reduce the surface shadow to a thin 3px blur, creating the convincing illusion that the button has been physically pressed down onto the surface.
.button-3d:active { transform: translateY(8px); box-shadow: #665367 0 0 0, #000 0 0 3px; }This technique creates a satisfyingly tactile experience for users, providing visual feedback that mimics a physical button press in the real world.
<button class="button-3d">CLICK</button> <style> .button-3d { border: none; background-color: #976D70; color: #fff; padding: 10px 20px; transition: 0.2s; border-radius: 6px; box-shadow: #665367 0 7px 2px, #000 0 8px 6px; cursor: pointer; } .button-3d:active { transform: translateY(8px); box-shadow: #665367 0 0 0, #000 0 0 3px; } </style>Thank you for reading this article.
Comments
No comments yet. Be the first to comment!