translate, rotate and scale as separate CSS properties
transform is one property with a list of functions. A hover effect that only wants to scale a card has to repeat the card’s existing translate(), or it removes it; an animation of the rotation overwrites the position set elsewhere. The individual transform properties translate, rotate and scale can be set, overridden and animated independently.
Problem: A theme’s cards are moved up by 4px on hover and an icon inside spins while loading. A block style that adds a slight rotation to “sticker” cards breaks both: the hover rule overwrites the rotation, and the rotation rule overwrites the hover lift.
Solution: Use rotate for the sticker style, translate for the hover lift and scale for the press effect, so each rule sets only its own property, and animate them separately with transitions or @keyframes.
The conflict with transform
/* before: three rules fighting over one property */
.ha-card:hover { transform: translateY(-4px); }
.ha-card.is-style-sticker { transform: rotate(-2deg); }
.ha-card.is-style-sticker:hover { transform: rotate(-2deg) translateY(-4px); } /* needed for every combination */
With individual properties
.ha-card {
transition: translate .2s ease, scale .1s ease;
}
.ha-card:hover {
translate: 0 -4px;
}
.ha-card:active {
scale: .98;
}
.ha-card.is-style-sticker {
rotate: -2deg;
}
Each rule sets only its own property, and all combinations work without extra rules: a sticker card keeps its rotation while it lifts on hover and shrinks a little when pressed. The transition lists exactly the properties that change.
The values:
translate: x y z, for exampletranslate: 0 -4pxortranslate: 50%(only x).rotate: anglearound the z-axis, orrotate: x 45deg/rotate: 1 1 0 45degaround an axis.scale: x y z, one value for uniform scaling.
Order of application
The individual properties are applied in a fixed order: first translate, then rotate, then scale, and after them the transform property, if it is also set. With transform the order is the one written in the list, which is why rotate() translate() and translate() rotate() give different results. If a specific order matters, keep using transform for that element.
Animations without overwriting
@keyframes ha-spin {
to { rotate: 360deg; }
}
.ha-icon.is-loading {
animation: ha-spin 1s linear infinite;
}
.ha-icon:hover {
scale: 1.1; /* works while it spins */
}
@media (prefers-reduced-motion: reduce) {
.ha-icon.is-loading { animation-duration: 3s; }
}
The keyframes animate only rotate, so the hover scale is not lost. With transform in the keyframes, the hover rule would be overwritten for the duration of the animation.
In block styles
A block style variation that adds a rotation now composes cleanly with the theme’s hover effects:
register_block_style( 'core/group', array(
'name' => 'ha-sticker',
'label' => __( 'Sticker', 'textdomain' ),
'inline_style' => '.wp-block-group.is-style-ha-sticker { rotate: -2deg; }',
) );
How block styles are registered: register_block_style.
NOTE: The individual transform properties are supported in all current browsers since 2022 (Chrome 104, Firefox 72, Safari 14.1). Like transform, they do not affect layout and are animated on the compositor, so they stay smooth. More on keyframe animations in themes: CSS animations and keyframes.