CSS View Transitions: smooth page transitions with one line of CSS
The author explains that CSS View Transitions lets a website animate page changes with one line of CSS: @view-transition { navigation: auto; }. Earlier, the same effect needed a lot of JavaScript that captured the old DOM[3] state and animated the change.
Both the current page and the destination page must include the rule, or the navigation is a normal hard one. The feature works only between pages of the same origin[2], and it works for link clicks and browser back and forward, but not for typing an address, bookmarks or reloads. If the files are opened from disk via file:///, the rule works only when it is placed in an inline style block.
By default, the whole page cross-fades. The author shows how to change this with the pseudo-elements[1] ::view-transition-old(root) and ::view-transition-new(root), for example to slow the fade down or to replace it with a slide. Single elements can also be animated by giving them the same view-transition-name on both pages. The author has added this feature to the next update of RocketCake, the website builder they are developing, where it can be turned on with one click.
Read the original irrlicht3d.orgDiscussion
Discussion
Commenters point out that the feature has existed in some browsers for about two years and ask whether bookmarks and history still work. One commenter answers that transitions appear on back and forward, while pages opened from a bookmark, a typed URL or a reload skip them. Others warn that transitions on every link can make a site feel slow, and they suggest short durations of 200–300 ms and the prefers-reduced-motion setting.
Sources
-
irrlicht3d.org
Page Transitions are now easy: CSS View Transitions



