P粉9304480302023-08-23 10:13:24
Edit: I am hesitant to delete this post. In terms of understanding CSS syntax, letting people know that all
exists is good, and depending on the structure of CSS, it may be preferable to a million separate declarations. On the other hand, it might have a performance penalty, although I haven't seen any data to support this assumption. I'll leave it at that for now, but I hope people realize it's a two-way street.
You can also simply use the following code:
.nav a { transition: all .2s; }
FWIW: If not specified, all
is the default, so transition: .2s;
can also achieve the same effect.
P粉0557261462023-08-23 09:42:12
In all browsers that support transition effects, transition attributes are separated by commas:
.nav a { transition: color .2s, text-shadow .2s; }
ease
is the default time function, so you don't need to specify it. If you really want linear
, you need to specify it explicitly:
transition: color .2s linear, text-shadow .2s linear;
This is starting to get repetitive, so if you're going to use the same time and time function on multiple properties, it's better to use the various transition-*
properties instead of the shorthand form:
transition-property: color, text-shadow; transition-duration: .2s; transition-timing-function: linear;