Home > Web Front-end > CSS Tutorial > CSS: @starting-style a new & cool at-rule

CSS: @starting-style a new & cool at-rule

DDD
Release: 2024-12-23 17:16:10
Original
228 people have browsed it

The @starting-style CSS at-rule is used to define starting values for properties set on an element that you want to transition from when the element receives its first style update, i.e. when an element is first displayed on a previously loaded page.

Let's take a toast message as an example. To display it to the user, we will change its visibility, but the result will be that it appears immediately. Now we can use the new @starting-style rule to define the starting animation for this element.

Some simple examples

Let's use this baseline HTML, a simple rectangle:

.container {
  width: 10rem;
  height: 10rem;
  background-color: hotpink;  
}
Copy after login

Add initial background-color transition from blue to pink

.container {
  ...
  transition: background-color 4s; 
}

@starting-style {
  .container {
    background-color: blue;
  }
}
Copy after login

CSS: @starting-style a new & cool at-rule

Add rotation to the previous example

.container {
  ...
  transition: transform 4s, background-color 4s;
  transform: rotate(0deg);} 
}

@starting-style {
  .container {
    background-color: blue;
    transform: rotate(360deg);
  }
}
Copy after login

CSS: @starting-style a new & cool at-rule

Anyways, you get the idea.
Animate your popups, and menus or create an animated logo,
It's straightforward.

NOTE

This feature currently has limited availability.

The above is the detailed content of CSS: @starting-style a new & cool at-rule. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template