Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS transition-delay Property

Posted in CSS Tutorial
Updated on Jul 15, 2024
By Mari Selvan
👁️ 16 - Views
⏳ 4 mins
💬 1 Comment
CSS transition-delay Property

Photo Credit to CodeToFun

🙋 Introduction

The transition-delay property in CSS is used to specify the amount of time to wait before the transition effect starts.

This property is useful for creating smoother animations and for controlling the timing of transitions on your web page. By adjusting the transition-delay, you can create more dynamic and visually appealing effects for your users.

💡 Syntax

The syntax for the transition-delay property is straightforward. It can be applied to any element that supports transitions.

Syntax
Copied
Copy To Clipboard
element {
  transition-delay: time;
}

Here, time can be specified in seconds (s) or milliseconds (ms).

🎛️ Default Value

The default value of the transition-delay property is 0s, meaning the transition starts immediately.

🏠 Property Values

ValueDescription
timeSpecifies the amount of time to wait before the transition effect starts. This can be in seconds (e.g., 2s) or milliseconds (e.g., 200ms).

📄 Example

In this example, we'll create a simple transition effect where the background color of a div changes after a delay of 2 seconds when the user hovers over it.

index.html
Copied
Copy To Clipboard
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS transition-delay Example</title>
  <style>
    .box {
      width: 100px;
      height: 100px;
      background-color: blue;
      transition: background-color 1s;
      transition-delay: 2s;
    }

    .box:hover {
      background-color: red;
    }
  </style>
</head>
<body>
  <h1>Transition Delay Example</h1>
  <div class="box"></div>
</body>
</html>

🖥️ Browser Compatibility

The transition-delay property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.

🎉 Conclusion

The transition-delay property is a powerful tool for web developers looking to create timed transitions and animations.

By adjusting the delay, you can control the timing of your effects, making your web pages more engaging and visually appealing. Experiment with different delay times and see how this property can enhance the user experience on your website.

👨‍💻 Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy