When setting transition-property
to all
, it looks bad when zooming inside the browser window, because width
and height
properties are also being transitioned. When I only want background
and color
, I need to define it multi line, though:
transition-property: color, background;
transition-duration: 250ms;
This is bad, because I also have to do it for -webkit-
, -moz
and -o-
. Instead I'm looking for something like this:
transition: [color and background] 250ms;
Is there any syntax for this?
Transitioning two or more properties You can transition two (or more) CSS properties by separating them with a comma in your transition or transition-property property. You can do the same with duration, timing-functions and delays as well. If the values are the same, you only need to specify one of them.
The transition-property property specifies the name of the CSS property the transition effect is for (the transition effect will start when the specified CSS property changes). Tip: A transition effect could typically occur when a user hover over an element.
transition-property. transition-duration. transition-timing-function. transition-delay.
The transition-property CSS property sets the CSS properties to which a transition effect should be applied.
When using the transition
shorthand with multiple transitions, you need to repeat the transition duration for each property, and separate each group of values with commas:
transition: color 250ms, background 250ms;
With prefixes, it looks like this:
-moz-transition: color 250ms, background 250ms;
-o-transition: color 250ms, background 250ms;
-webkit-transition: color 250ms, background 250ms;
transition: color 250ms, background 250ms;
Still a little repetitive, but at least it beats repeating transition-property
and transition-duration
for all the prefixes.
The shorthand syntax is described in the spec.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With