Urgent.News

What's breaking now, across thousands of outlets.

Tech

Entry Animations with CSS @starting-style

Entry animations can be tricky—between handling DOM load times and animating from display: none , it's easy to get stuck. The @starting-style rule simplifies this by letting you explicitly set starting values for CSS properties when an element first loads, creating smoother transitions right from the get-go. You can view the complete post with additional examples here . The Basics @starting-style…

CSS @starting-style is a powerful tool for creating smooth entry animations on web elements. It addresses common challenges when animating from display: none by defining explicit starting values for CSS properties at the moment an element first loads. This rule simplifies the process of creating transitions right from the start, resulting in smoother and more visually appealing effects.

To leverage @starting-style, you can either nest it within an element's ruleset or define it separately using a selector. However, it's important to note that nesting @starting-style within a pseudo-element (such as ::before or ::after) is not supported, as the styles will apply to the main element instead of the pseudo-element.

The @starting-style at-rule shares the same specificity as the original rule, so placing the @starting-style at-rule after the original rule ensures proper application of starting styles. This rule works hand-in-hand with the transition property, where the @starting-style defines the initial state before an element becomes visible, and the transition defines the final state.

One practical application of @starting-style is in creating entry effects or transitions for elements that are initially hidden, particularly when transitioning from display: none to a visible state. For example, you can use @starting-style to animate text fading in on page load or to create smooth transitions for popups and dialogs.

A notable advantage of using @starting-style is its ability to handle smooth transitions for elements that change from display: none to display: block. Typically, animating such a transition would be difficult due to the change in the display property, but @starting-style provides a solution by defining an initial state for the element once it becomes visible.

An illustrative example is the use of the dialog element, where its body switches between display: none and display: block when toggled. Without @starting-style, animating this transition would be impossible due to the display property change. However, @starting-style allows you to define the initial state of the element (opacity: 0) and then smoothly transitions it to the final state (opacity: 1) using a transition property.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

I built a chat app solo — rooms, voice/video calls, E2EE, and in-room games

I didn't want to build another messenger. There are plenty. What I wanted was a place where you walk into a room built around a shared interest — movies, music, gaming — and people are just...

  • Developer created PTT Chat in 2021 to enable themed interest-based rooms
  • Features include topic rooms, voice/video calls, E2EE, and in-room games
  • App uses Node.js, Express, Socket.io, SQLite, and WebRTC for calls

London’s Foundational exits stealth with €9.6 million to track satellites and debris with “millimetre-level” precision

Foundational, a London-based SpaceTech startup developing infrastructure for a more precise understanding of Earth and orbit, has emerged from stealth with €9.6 million (£8.2 million) in pre-Seed…

  • Foundational startup exits stealth with €9.6 million funding
  • Investors include Inflection, BACKED, Final Frontier, Adjacent, and Type One Ventures
  • Company automates Satellite Laser Ranging for millimetre-level precision

More from Thursday 1 October →