CSS - Transition

Transition

In this tutorial, I will be showing you how to use the transition properties to animate element in your web page.

definition
DEFINITION:

Transition is the change from one state to another

Transition Properties

transition - shorthand property that use to for setting all transition properties. The syntax is as follows: transition: transition-property transition-duration transition-timing-function transition-delay

transition-property - name of the CSS property you want to apply transition effect to. For example: width, padding, background-color, etc.

note
NOTE:

Not all CSS properties can be used for transition-property.
Only CSS properties that has numbers, lengths, percentage and inches can be used.
transition-duration is NOT optional, it must be specified.


transition-duration - amount of time (in seconds or milliseconds) the transition should use from start to end.

transition-timing-function - used to specify how the intermediate values in-between the start and the end of the transition should be calculated. It specifies the speed curve of the transition.

  • ease - starts slowly, accelerates to the middle and slows down at the end.
  • ease-in - starts slowly then accelerates towards the end.
  • ease-out - starts quickly the accelerates towards the end.
  • ease-in-out - combines both ease-in and ease-out characteristics.
  • cubic-bezier(p1, p2, p3, p4) - transition which allows you define your own cubic-bezier function. NB: Values must be from 0 and 1.
  • linear - transition at an even speed; same as cubic-bezier (0.0, 0.0, 1.0, 1.0).
  • steps(n, jumpterm) transition which can be divided into n stops with each stop lasting an equal amount of time.
  • step-end - similar to steps(1, jump-end)
  • step-start - similar to steps(1, jump-start)
  • jump-start - defines a left continuous function, that repeats as the transition starts at the point where the first jump occurs.
  • jump-end - defines a right continuous function, that repeats as the final jump occurs at the end of the transition.
  • jump-none - no jump occurs at both ends, it maintains position of 0% and 100% mark for each duration of 1/n.
  • jump-both - parses at both 0% and 100% marks and adds a step to the transition time.
  • start - similar to jump-start.
  • end - similar to jump-end.

transition-delay - amount of time (in seconds or milliseconds) it takes before the transition will start.

tips
TIP:

You can use transition with transform property
You can also have multiple transition element.


ADVERTISEMENTS

LEARNING IS A CONTINOUS PROCESS - PRACTICE MAKES PERFECT