CSS Animations, Exercises, Training and Custom Properties and CSS Functions | Transitions, Transformations and Animations

CSS animations allow you to create dynamic and engaging visual effects on your web pages. They involve defining keyframes, which specify the styles at different points in time, and then applying the animation to elements using the animation property.

Syntax:

CSS

@keyframes animation-name {

  0% { /* Styles for the start of the animation */ }

  50% { /* Styles for the middle of the animation */ }

  100% { /* Styles for the end of the animation */ }

}

.element {

  animation: animation-name 2s ease-in-out;

}

Common Animation Properties

  • animation-name: Specifies the name of the animation.
  • animation-duration: Sets the duration of the animation.
  • animation-timing-function: Defines the timing function of the animation (e.g., linear, ease-in, ease-out). 
  • animation-delay: Sets the delay before the animation starts.
  • animation-iteration-count: Specifies the number of times the animation should repeat. 
  • animation-direction: Sets the direction of the animation (e.g., normal, reverse, alternate).
  • animation-fill-mode: Specifies what happens before and after the animation.

Exercises

  1. Create a fading animation for a button.
  2. Animate an element to slide in from the left.
  3. Create a rotating element.
  4. Animate a progress bar.
  5. Combine multiple animations for complex effects.

Training

  • Online tutorials: There are many online tutorials and courses available that cover CSS animations.
  • Interactive exercises: Practice creating animations using interactive exercises.
  • Experimentation: Experiment with different animation properties and values to create unique effects.

CSS Custom Properties

CSS custom properties (also known as variables) allow you to define custom values that can be used throughout your stylesheet. This makes it easier to manage and update styles, especially in responsive web design.

Syntax:

CSS

:root {

  –primary-color: blue;

  –secondary-color: red;

}

.element {

  color: var(–primary-color);

  background-color: var(–secondary-color);

}

CSS Functions

CSS functions provide built-in functionality for various tasks, such as color manipulation, calculations, and more.

Common CSS Functions

  • calc(): Performs calculations on values.
  • hsl(): Creates colors using hue, saturation, and lightness.
  • rgb(): Creates colors using red, green, and blue values.
  • rgba(): Creates colors with an alpha channel (opacity).
  • hsl(): Creates colors using hue, saturation, and lightness.
  • hsla(): Creates colors with an alpha channel (opacity).

Example:

CSS

.element {

  width: calc(100% – 20px);

  background-color: hsl(200, 50%, 70%);

} By combining CSS animations, custom properties, and functions, you can create dynamic and visually appealing responsive web designs.

Learning about the Translate3D Property | Transitions, Transformations and Animations
Introduction to CSS Functions and Custom Properties | Custom Properties and CSS Functions

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?