If you are bored because you have to play with text and color in web design, let me introduce you to unique, bombshell, explosion-worthy property. OK, maybe not so much explosive but you are going to enjoy it. CSS follows and supports your willing to spice things up and that is why there is a transition option.
The transition property allows changing the CSS property values smoothly.
It is necessary to define a property that will be changed and the duration of the effect.
transition: background 1s;
-webkit-transition: background 1s; /* Safari */
These two values can be defined with the universal property
transition or with individual properties
Some of the
transition-property values I can remember at the moment are:
If the value is defined with a property, defines a comma-separated list of CSS property names the transition effect is for. The value all is the default one and defines that all properties that can transition will transition. In this case, all changed properties will have a transition with the same
timing if defined).
transition-duration property is very simple, it defines how much time a transition effect takes to complete, and its value can be defined in seconds (s) or milliseconds (ms).
Additional properties connected to transition are:
Very similar to the duration property,
transition-delay is defined with seconds (s) or milliseconds (ms) and specifies when the transition effect will start. This property can be negative, unlike the duration property, and if that so it will begin part-way through its play cycle.
transition-timing-function property is defined by the following functions:
transition: background 1s ease-in-out 2s;
-webkit-transition: background 1s ease-in-out 2s; /* Safari */
With the universal property
transition you can define all four properties, just keep in mind that first time defined is always
It’s possible to make the multiple transitions set. To split different transitions use
transition: background 1s ease-in-out 2s, width 2s linear;
-webkit-transition: background 1s ease-in-out 2s, width 2s linear; /* Safari */
The main thing to remember about the transition is that this property is defined before and it’s going to happen only if it’s triggered (if the property which is defined with transition-property is changed).
This property is widely supported so use it! If you need some inspiration, check out this example.
Originally published at kolosek.com on April 10, 2018.