20
loading...
This website collects cookies to deliver better user experience
The thicker the button, the longer and more diffuse shadows are.
button {
/* Use realistic shadows */
box-shadow: 1px -1px 2px 0 hsla(0, 0%, 0%, 0.06),
3px -3px 4px 0 hsla(0, 0%, 0%, 0.08);
}
/* On button press */
button:active {
/* Make shadows much smaller */
box-shadow: 0 0 1px 0 hsla(0, 0%, 0%, 0.06),
1px -1px 1px 0 hsla(0, 0%, 0%, 0.08);
}
button {
/* Make sure that transform-origin match translate() direction.
It makes translate() and scale() work it the same axis */
transform-origin: bottom center;
}
/* On button press */
button:active {
/* Apply perspective transformation */
transform:
/* Translate down on Y axis */
translatey(0.25em)
/* Make button smaller */
scale(0.98);
}
transition
is not always necessary for small scale transformations. It's like in classic animation. Our mind will fill the gaps. transition
to keep them pressed for a bit longer. It'll help the user to see the impact of clicking it.button {
/* Add short transition with a delay
This transition will control second half of the animation */
transition:
transform 50ms ease-in 10ms,
box-shadow 50ms ease-in 10ms;
}
/* On button press */
button:active {
/* Add short transition
This transition will control first half of the animation */
transition:
transform 50ms ease-in,
box-shadow 50ms ease-in;
}
button {
padding-top: 1rem;
/* Make bottom padding slightly larger */
padding-bottom: 1.05rem;
}