Mastering CSS Transition Properties


CSS transition properties are used to define the behavior and appearance of CSS transitions, which allow for smooth animations and changes in CSS property values over time. These properties control how the transition occurs, including its duration, timing function, and delay.

CSS transitions allow you to adjust property values smoothly over time.To observe a CSS transition effect, hover your cursor over the element below:

transition :

  • transition-property
  • transition-duration
  • transition-delay
  • transition-timing-function

transition-property :

This property specifies which CSS properties should be transitioned. It accepts a comma-separated list of property names, or the value "all" to transition all properties that are changed. For syntax:

selector {
transition-property: (width, height, background-color);
}
 

In this syntax, transitions will occur for changes in the width, height, and background-color properties of the .element element.

transition-duration :

This property specifies the duration of the transition in seconds or milliseconds. It determines how long it takes for the transition to complete. For syntax:

selector{
transition-duration: timing (in seconds); 
}
 

transition-timing-function :

This property specifies the timing function used for the transition, which determines how the intermediate property values are calculated during the transition. Common values include ease (default), linear, ease-in, ease-out, ease-in-out, and various cubic-bezier values for custom timing functions

transition-delay :

This property specifies a delay before the transition starts, in seconds or milliseconds. It allows you to delay the start of the transition after a property change.For syntax::

.element {
transition-delay: timing (in seconds); 
}
 

CSS transition properties are used in combination to create smooth and visually appealing animations for web design. By defining the transition property, duration, timing function, and delay, you can control how elements on a webpage smoothly transition from one state to another, adding dynamic and engaging effects to your web pages.

Transitions :

In CSS (Cascading Style Sheets), transitions are used to animate the changes in property values of HTML elements smoothly over a specified duration. Transitions add visual effects to web pages, making them more interactive and engaging for users.

CSS transitions are applied to specific properties of an element, such as width, height, opacity, color, and more. When the value of a property changes, the transition effect is triggered, and the element smoothly transitions from its current state to the new state.

The syntax for defining a CSS transition is as follows:

transition:property duration timing-function delay; 
  • property: Specifies the CSS property that you want to apply the transition effect to. For example, width, height, opacity, etc.
  • duration: Specifies the duration of the transition effect in seconds (s) or milliseconds (ms). For example, 0.5s or 500ms.
  • timing-function: Specifies the timing function for the transition, which determines how the intermediate property values are calculated over time. Common values include ease (default), linear, ease-in, ease-out, ease-in-out, and cubic-bezier.
  • delay: Specifies an optional delay before the transition effect starts, in seconds (s) or milliseconds (ms).

CSS transitions provide a simple way to add animations to web pages without the need for JavaScript or complex CSS animations. They can be used to create various effects, such as fading, sliding, scaling, and more, making web pages more dynamic and visually appealing.

Source Code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

    *{
      font-family: 'Poppins', sans-serif;
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    body{
      padding: 10px;

    }
    .container{
      width: 900px;
      margin: 0 auto;
    }
    h3{
      margin-top: 20px;
      margin-bottom: 20px;
      padding-top: 10px;
      padding-bottom: 10px;
      border-top: 1px solid rgba(161, 161, 161,0.3);
      border-bottom: 1px solid rgba(161, 161, 161,0.3);

    }
    .box{
      width: 100px;
      height: 100px;
      background-color: #333;
    }

    .box:hover{
      width: 300px;
    }
    .ball{
      width: 100px;
      height: 100px;
      background-color: orangered;
      margin-top: 20px;
    }
    .ball:hover{
     border-radius: 50%;
    }
    .trans{
      transition: 0.5s;
 transition-timing-function: cubic-bezier(0.075, 0.82, 0.165, 1);
    }
    ul li{
      list-style: decimal;
      margin-bottom: 10px;
      margin-left: 25px;
    }
    p{
      padding: 10px;
    }
  </style>
</head>
<body>
  <div class="container">
    <h1>Tutor Joe's</h1>
    <h3>Transition</h3>
    <p>CSS transitions allow you to adjust property values smoothly over time.To observe a CSS transition effect, hover your cursor over the element below:</p>
    <ul>
        <li>transition</li>
        <li>transition-property</li>
        <li>transition-duration</li>
        <li>transition-delay</li>
        <li>transition-timing-function</li>
    </ul>
    <h3>Without Transition</h3>
    <div class="box"></div>
    <div class="ball"></div>
    <h3>With Transition</h3>
    <div class="box trans"></div>
    <div class="ball trans"></div>
  </div>
</body>
</html>

Live Preview


CSS Tutorial


Properties Reference


Cascading Style Sheet


Flexbox Tutorial


CSS Grid Tutorial


Transitions Properties


CSS Properties with Examples


CSS Selectors


CSS Pseudo Elements


CSS Attribute Selectors


Input Pseudo Classes


CSS Examples


CSS Animation Projects