brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: @view-transition navigation: auto gives css page fades between your own pages

Css
~/tips/tip-css-view-transition-navigation-auto

@view-transition { navigation: auto; }

Animates navigation between two same-origin pages with a cross-fade, using only a stylesheet rule.

A simple cross-fade between pages used to need a JavaScript router.

@view-transition { navigation: auto; }
::view-transition-old(root) { animation-duration: .2s; }
::view-transition-new(root) { animation-duration: .2s; }

With this at-rule on both pages, a browser that supports cross-document view transitions animates the switch between them, a fade by default. Chrome and Edge support it since version 126 and Safari since 18.2. Firefox support is still partial, and MDN marks the feature as limited availability. Both pages must be on the same origin. The two pseudo-elements adjust the duration of the old and new snapshot. Other browsers just navigate as usual, so it works as an enhancement. Wrap the animation rules in a prefers-reduced-motion check for visitors who want less movement.

Further reading: MDN: @view-transition

More Css tips CSS Overview in Chrome DevTools audits the colors and fonts of a page .notice:empty { .toast { article { counter-reset: h2; } .toolbar { All Css tips (66) All topics

Link