Beyond Static: CSS Animation
Sobre a Aula

Simple animations using transitions

In this topic, we will explore simple animations using CSS transitions.

Transitions allow smoothing the change of properties, creating visually appealing effects on HTML elements.

To begin, consider the following example. Let’s say you want to smooth the color change of a button when hovering over it.

Using transitions, this can be done simply:

/* Setting the initial button style */
button {
  background-color: #3498db;
  transition: background-color 0.3s ease;
}

/* Applying the transition on hover */
button:hover {
  background-color: #2980b9;
}

In this code, the transition property is used to specify that any change in the background-color property should occur over 0.3 seconds with a smooth transition function (ease).

When hovering over the button, the color will change smoothly, providing a pleasant visual experience.

Remember that this is just a simple example. Transitions can be applied to a variety of properties, such as width, height, opacity, among others.

Try exploring different properties and values to customize your animations according to the needs of your project.

Entrar na conversa
Rolar para cima