📜  CSS pause-before(1)

📅  最后修改于: 2023-12-03 15:00:05.597000             🧑  作者: Mango

CSS pause-before

CSS pause-before property specifies how long an element should pause before playing an animation or transitioning.

Syntax
pause-before: time | initial | inherit;
  • time: Specifies the time in seconds or milliseconds. It can be a decimal number or a whole number. The default value is 0s.

  • initial: Sets this property to its default value, which is 0s.

  • inherit: Inherits this property from its parent element.

Examples
Example 1

The following example shows how to use pause-before to pause the animation for 2 seconds before it starts.

div {
  animation: slideshow 10s infinite;
  pause-before: 2s;
}

@keyframes slideshow{
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
Example 2

In the following example, the pause-before property is used to pause the transition for 1 second before it starts.

div {
  width: 100px;
  height: 100px;
  background-color: red;
  transition: width 2s;
  pause-before: 1s;
}

div:hover {
  width: 200px;
}
Browser Support

The pause-before property is supported in all modern browsers.

Conclusion

The pause-before property is a useful tool for controlling animations and transitions. It allows you to pause them before they start, giving you more control over the timing and duration of your animations and transitions.