3D animations in a cross-document view transition fail unless you stop relying on the perspective property and move to the perspective() transform function instead. The setup below explains why, starting from a working in-page example.
The baseline: a working 3D flip
Images make a useful reduced test case here. They are replaced elements, just like the snapshots a browser takes of the before and after states in a view transition. Flipping one image to reveal another on click is therefore a reasonable stand-in for the real thing.
For the flip to read as 3D, the perspective property has to sit on the image's parent container — here, the .scene element. Without it, the transformation is merely flat and only appears to angle the element. In CSS, a parent's perspective applies to all its children and excludes itself:
.scene {
perspective: 1200px;
.card { /* gets perspective */ }
}
The HTML structure matters: the .scene container sits on top of the child .card elements, which is what brings the 3D effect to life.
<div class="scene">
<div class="card">
<!-- Card Content Here -->
</div>
</div>
The keyframe animation for flipping the .cards looks something like this:
@keyframes flipOut {
from {
transform: rotateY(0deg);
}
to {
transform: rotateY(-90deg);
}
}
…and it is applied to the .cards like this:
.card.flip-out {
animation: flipOut 5.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.card.flip-in {
animation: flipOut 5.2s cubic-bezier(0.4, 0, 0.2, 1) forwards reverse;
}
The animation runs forwards when JavaScript appends the .flip-out class on click, and in reverse when it appends .flip-in.
Applied broadly, this is also the shape a cross-document view transition ought to take: if an image supports a 3D animation, a view transition snapshot should behave the same way.
Setting up the view transition
First, both pages must opt in with the @view-transition at-rule, setting the navigation descriptor to auto:
@view-transition {
navigation: auto;
}
With nothing else added, one page fades into the other — the most basic of all cross-document view transitions.
Customisation happens through the ::view-transition-old() and ::view-transition-new() pseudo-classes, which hold the old and new snapshots respectively. As with the .card elements in the previous example, that is where the keyframe animation is set:
::view-transition-old(root) {
/* animation goes here */
}
::view-transition-new(root) {
/* animation goes here */
}
The root parameter targets the whole page, along with every element created (and not created) by the view transition's default snapshot group.
Where the flip falls apart
Applying the same flip to the entire page — the old snapshot rotating into the new one — requires the two things any 3D animation needs: perspective on the parent element, and an animation that fires when the view transition happens.
That raises a question: what exactly is the parent element here? Since view transitions snapshot the whole webpage, the logical guess is the <html> element (or :root). The DOM tree with a view transition present looks like this:
html
├─ ::view-transition
│ ├─ ::view-transition-group(card)
│ │ └─ ::view-transition-image-pair(card)
│ │ ├─ ::view-transition-old(card)
│ │ └─ ::view-transition-new(card)
│ └─ ::view-transition-group(name)
│ └─ ::view-transition-image-pair(name)
│ ├─ ::view-transition-old(name)
│ └─ ::view-transition-new(name)
├─ head
└─ body
└─ …
Turns out that assumption is wrong — the version above does nothing at all, and you get a flat result rather than the clean 3D flip achieved with the cards:
Here is the code in play:
/* Cross-document View Transition opt-in */
@view-transition {
navigation: auto;
}
/* 3D flip: Old page flips away, new page flips in */
@keyframes flip-out {
0% {
transform: rotateY(0deg);
opacity: 1;
}
100% {
transform: rotateY(-90deg);
opacity: 0;
}
}
@keyframes flip-in {
0% {
transform: rotateY(90deg);
opacity: 0;
}
100% {
transform: rotateY(0deg);
opacity: 1;
}
}
::view-transition-old(root) {
animation: flip-out 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
transform-origin: center center;
}
::view-transition-new(root) {
animation: flip-in 0.3s cubic-bezier(0, 0, 0.6, 1) 0.3s backwards;
transform-origin: center center;
}
Note: the animation is not reversed in this case, since the flip goes to -90deg and then from 90deg — not the same motion.
Placing perspective on html or on :root makes no difference:
/* 👎 */
html {
perspective: 1100px;
}
/* 👎 */
:root {
perspective: 1100px;
}
perspective and 3D transformations generally fall among the CSS properties that would produce an unusual effect in this context. Other approaches don't fare any better: setting perspective on the body, inside ::view-transition-group(root), or inside the ::view-transition pseudo all fail.
The fix: use the function, not the property
The workaround is to skip the perspective property entirely and use the perspective() function instead — not inside any ::view-transition-* pseudo, but inside the @keyframes animation:
@keyframes flip-out {
0% {
transform: perspective(1100px) rotateY(0deg);
opacity: 1;
}
100% {
transform: perspective(1100px) rotateY(-90deg);
opacity: 0;
}
}
@keyframes flip-in {
0% {
transform: perspective(1100px) rotateY(90deg);
opacity: 0;
}
100% {
transform: perspective(1100px) rotateY(0deg);
opacity: 1;
}
}
This single change takes the scene from flat to a proper 3D result:
The reason is how the view transition pseudo-element tree renders: outside the normal HTML flow, above the DOM in its own layer. For ::view-transition specifically, the likely explanation is that each view transition group's position and transform values are overridden by the browser, which interferes with perspective.
The distinction comes down to where each form applies. The perspective property targets the parent element; the perspective() function is a transform function applied directly to the element itself. Because the view transition pseudo tree has no true parent, only the function form can work.
What to remember
Setting perspective on html, :root, body, or any view transition pseudo-class won't produce a 3D flip. The perspective() function inside the @keyframes will. The property expects a parent that the pseudo tree doesn't provide; the function expects only the element.



