Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 23, 2017 04:43 pm GMT

Individual CSS Transform Functions

Dan Wilson documents a classic annoyance with transforms:

button {
transform: translateY(-150%);
}
button:hover {
/* will (perhaps unintentionally) override the original translate */
transform: scale(.8);
}

The native (and WET) solution is list the original transform again:

button:hover {
transform: translateY(-150%) scale(.8);
}

Dan's trick is to use custom properties instead. Set them all on the element right up front, then re-set them the :hover state:

:root {
--tx: 150%;
--scale: 1;
}
button {
transform:
translateY(var(--tx))
scale(var(--scale));
}


Individual CSS Transform Functions is a post from CSS-Tricks


Original Link: https://danielcwilson.com/blog/2017/02/individual-transforms/

Share this article:    Share on Facebook
View Full Article

CSS Tricks

A Web Design Community curated by Chris Coyier

More About this Source Visit CSS Tricks