23. Transition

To create a transition between 2 states, such as an element at rest whose hover pseudo-class becomes active, we have different configurations available.

Duration

Time the transition will last.

.elemento {
  /* Default */
  transition-duration: 0s;

  /* 2 seconds */
  transition-duration: 2s;
}

More information

Property

Defines which property you want to apply the transition to.

.elemento {
  /* Default */
  transition-property: all;

  /* Only to one property, such as the width */
  transition-property: width;
}

More information

Timing function

Function that defines the curve of the animation.

.elemento {
  /* Default */
  transition-timing-function: ease;

  /* Other preset functions */
  transition-timing-function: ease-in;
  transition-timing-function: ease-out;
  transition-timing-function: ease-in-out;
  transition-timing-function: linear;


  /* Custom */
  transition-timing-function: cubic-bezier(0.1, 0.7, 1.0, 0.1);
}

You can interact with several examples, and even discover new ones, at easings.net.

More information

Delay

Time it will take to start.

.elemento {
  /* Default */
  transition-delay: 0s;

  /* 1 second */
  transition-delay: 1s;
}

More information

Activity 1

Build a form with the following fields:

  • Name, text type.
  • Phone, number type.
  • Submit button.

When the first 2 fields, name or phone, have focus, fade out their borders with a smooth transition and slightly increase their size so they read better.

On the other hand, the button must lose its background color when the cursor is over it.

Building SPAs with Django and HTML Over the Wire: Learn to build real-time single page applications with Python

Building SPAs with Django and HTML Over the Wire: Learn to build real-time single page applications with Python

The HTML over WebSockets approach simplifies single-page application (SPA) development and lets you bypass learning a JavaScript rendering framework such as React, Vue, or Angular, moving the logic to Python. This web application development book provides you with all the Django tools you need to simplify your developments with real-time results.

Buy the book

Help me keep writing

Every coffee gives me a push toward the next article.

Comments

There are no comments yet.