GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

`view-timeline` CSS property

The view-timeline CSS shorthand property defines a named view progress timeline's name, direction, and inset values.

The **`view-timeline`** [CSS](/docs/Web/CSS) [shorthand](/docs/Web/CSS/Guides/Cascade/Shorthand_properties) property defines a [named view progress timeline's](/docs/Web/CSS/Guides/Scroll-driven_animations/Timelines#named_view_progress_timeline) name, direction, and inset values.

## Constituent properties

This property is a shorthand for the following CSS properties:

- view-timeline-axis
- view-timeline-inset
- view-timeline-name

## Syntax

```css
/* One component */
view-timeline: none;
view-timeline: --custom_name_for_timeline;

/* Two components */
view-timeline: --custom_name_for_timeline block;
view-timeline: --custom_name_for_timeline y;
view-timeline: none inline;
view-timeline: none x;

/* Three components */
view-timeline: --custom_name_for_timeline block auto;
view-timeline: --custom_name_for_timeline block 20% 200px;

/* Global values */
view-timeline: inherit;
view-timeline: initial;
view-timeline: revert;
view-timeline: revert-layer;
view-timeline: unset;
```

### Values

- `<view-timeline-name>`
- : See view-timeline-name. The default value is `none`.
- `<view-timeline-inset>`
- : See view-timeline-inset. The default value is `auto`.
- `<view-timeline-axis>`
- : See view-timeline-axis. The default value is `block`.

## Description

The `view-timeline` shorthand property defines a _named view progress timeline_, which progresses based on changes to the visibility of an element (the _subject_) within a scrollable element (_scroller_). The `view-timeline` property is set on the subject. If the scroller element does not overflow its container in the axis dimension or if the overflow is hidden or clipped, no scroll progress timeline will be created.

The subject's visibility inside the scroller is tracked — by default, the timeline is at `0%` when the subject is first visible at one edge of the scroller and `100%` when it reaches the opposite edge.

The `view-timeline` can contain three constituent values: a name for the named view progress timeline, a scroll axis value, and up to two timeline inset values.
If only one value is declared, the value is the `view-timeline-name`. The name is then referenced in an animation-timeline declaration to indicate the element that will be animated as the timeline progresses. This can be the subject element, but it doesn't have to be — you can animate a different element as the subject moves through the scrolling area.

The `view-timeline` shorthand property can be applied to a container element to set a combination of the `<view-timeline-name>`, `<view-timeline-inset>`, and `<view-timeline-axis>` values. At least one value must be specified. If all values are specified, the order must be `<view-timeline-name>` followed by `<view-timeline-axis>` and/or `<view-timeline-inset>`.

The names specified in the `<view-timeline-name>` component must be a list of comma-separated dashed-ident values (which means they must start with `--`) or the keyword `none`.

## Formal definition

## Formal syntax

## Examples

### Creating a named view progress timeline

A view progress timeline named `--subject-reveal` is defined using the `view-timeline` property on a subject element with a `class` of `animation`.
This is then set as the timeline for the same element using `animation-timeline: --subject-reveal`. The result is that the subject element animates as it moves upwards through the document as it is scrolled.

#### HTML

The HTML for the example is shown below.

```html
<div class="content">
<h1>Content</h1>

<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Risus quis varius quam
quisque id. Et ligula ullamcorper malesuada proin libero nunc consequat
interdum varius. Elit ullamcorper dignissim cras tincidunt lobortis feugiat
vivamus at augue.
</p>

<p>
Dolor sed viverra ipsum nunc aliquet. Sed sed risus pretium quam vulputate
dignissim. Tortor aliquam nulla facilisi cras. A erat nam at lectus urna
duis convallis convallis. Nibh ipsum consequat nisl vel pretium lectus.
Sagittis aliquam malesuada bibendum arcu vitae elementum. Malesuada bibendum
arcu vitae elementum curabitur vitae nunc sed velit.
</p>

<div class="subject animation"></div>

<p>
Adipiscing enim eu turpis egestas pretium aenean pharetra magna ac. Arcu
cursus vitae congue mauris rhoncus aenean vel. Sit amet cursus sit amet
dictum. Augue neque gravida in fermentum et. Gravida rutrum quisque non
tellus orci ac auctor augue mauris. Risus quis varius quam quisque id diam
vel quam elementum. Nibh praesent tristique magna sit amet purus gravida
quis. Duis ultricies lacus sed turpis tincidunt id aliquet. In egestas erat
imperdiet sed euismod nisi. Eget egestas purus viverra accumsan in nisl nisi
scelerisque. Netus et malesuada fames ac.
</p>
</div>
```

#### CSS

The `subject` element and its containing `content` element are styled minimally, and the text content is given some basic font settings:

```css
.subject {
width: 300px;
height: 200px;
margin: 0 auto;
background-color: deeppink;
}

.content {
width: 75%;
max-width: 800px;
margin: 0 auto;
}

p,
h1 {
font-family: "Helvetica", "Arial", sans-serif;
}

h1 {
font-size: 3rem;
}

p {
font-size: 1.5rem;
line-height: 1.5;
}
```

The `<div>` with the class of `subject` is also given a class of `animation` — this is where `view-timeline` is set to define a named view progress timeline. It is also given an `animation-timeline` name with the same value to declare that this will be the element animated as the view progress timeline progresses.

Lastly, an animation is specified on the element that animates its opacity and scale, causing it to fade in and grow as it moves up the scroller.

```css
.animation {
view-timeline: --subject-reveal block;
animation-timeline: --subject-reveal;

animation-name: appear;
animation-fill-mode: both;
animation-duration: 1ms; /* Firefox requires this to apply the animation */
}

@keyframes appear {
from {
opacity: 0;
transform: scaleX(0);
}

to {
opacity: 1;
transform: scaleX(1);
}
}
```

```css hidden
@layer no-support {
@supports not (view-timeline: none) {
body::before {
content: "Your browser doesn't support the `view-timeline` property.";
background-color: wheat;
display: block;
text-align: center;
padding: 1rem 0;
}
}
}
```

#### Result

Scroll to see the subject element being animated.

100%

## Specifications

## Browser compatibility

## See also

- animation-timeline
- view-timeline-axis, view-timeline-inset, view-timeline-name
- view()
- [Guide: CSS scroll driven animation timelines](/docs/Web/CSS/Guides/Scroll-driven_animations/Timelines#named_view_progress_timeline)
- [CSS scroll-driven animations](/docs/Web/CSS/Guides/Scroll-driven_animations)

source: MDN Web Docs mirror · page

Cite this

"`view-timeline` CSS property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/view-timeline

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·