Skip to content

Commit af03a4a

Browse files
committed
fix: clarify setting multiple view transition classes
1 parent 45205c5 commit af03a4a

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/content/docs/basics/styling.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,9 @@ Like with CSS classes, you can even have multiple view transition classes one se
357357
/* ... */
358358
}
359359
```
360-
Make sure you have no whitespace in such a selector.
360+
Make sure you don't have whitespace before or after the dots in such a selector.
361+
362+
As usual in CSS, there is always only a single relevant declaration to set a property. The `view-transition-class` property is no exception. If you want to set multiple classes, you have to set them in a single declaration. Accumulating classes in multiple declarations will not work.
361363

362364
The above selector selects all groups that have both view transition classes:
363365

@@ -367,9 +369,7 @@ The above selector selects all groups that have both view transition classes:
367369
view-transition-class: special card; /* will be selected, order does not matter */
368370
view-transition-class: card something special /* also fine, element might have additional classes */
369371
```
370-
371-
The view transition class names for a group and all its children are defined when the group is last encountered [during capturing](/basics/pseudos/#view-transition-names). A group that is present in the new state will have the class names defined in the new state styles. Only groups that were only present in the old state will have the view transition class names defined on the old state styling. This holds for both, same-document and cross-document view transitions.
372-
372+
373373
Does that sound a bit complicated? Good news: the most common case is also the simplest: the `*` can be omitted in selectors that use view transition class names. With a single class, the `nav-link` example from above then looks like this:
374374

375375
```css
@@ -378,6 +378,10 @@ Does that sound a bit complicated? Good news: the most common case is also the s
378378
}
379379
```
380380

381+
#### Class Names come Mainly from the New State
382+
The view transition class names for a group and all its children are defined when the group is last encountered [during capturing](/basics/pseudos/#view-transition-names). A group that is present in the new state will have the class names defined in the new state styles. Only groups that were only present in the old state will have the view transition class names defined on the old state styling. This holds for both, same-document and cross-document view transitions.
383+
384+
381385

382386
### …with Types
383387

0 commit comments

Comments
 (0)