animation-range-start

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The animation-range-start CSS property is used to set the start of an animation's attachment range along its timeline, i.e., where along the timeline an animation will start.

Syntax

css
/* Keyword or length percentage value */
animation-range-start: normal;
animation-range-start: 20%;
animation-range-start: 100px;

/* Named timeline range value */
animation-range-start: cover;
animation-range-start: contain;
animation-range-start: cover 20%;
animation-range-start: contain 100px;

Values

normal

Represents the start of the timeline. This is the default value.

<length-percentage>

A length or percentage value measured from the beginning of the timeline.

<timeline-range-name>

A specific named timeline range inside the overall timeline, starting at 0%.

<timeline-range-name> <length-percentage>

A specified percentage or distance through a named timeline range, measured from the start of that timeline range.

Description

In the case of <timeline-range-name> values that do not include a <length-percentage>, the percentage defaults to 0%.

Allowed values for animation-range-start are normal, a <length-percentage>, a <timeline-range-name>, or a <timeline-range-name> with a <length-percentage> following it. See animation-range for a detailed description of the available values.

Also check out the View Timeline Ranges Visualizer, which shows exactly what the different values mean in an easy visual format.

The animation-range-start and animation-range-end properties can also be set using the animation-range shorthand property.

The animation-range-start is included in the animation shorthand as a reset-only value. This means that the animation resets a previously-declared animation-range-start value of equal or lower specificity to normal, but the range start value cannot be set via an animation shorthand declaration. For this reason, when creating ranges for CSS scroll-driven animations, you should declare animation-range-start after declaring any animation shorthand for it to take effect.

Formal definition

Initial valuenormal
Applies toall elements
Inheritedno
PercentagesRelative to the specified named timeline range if specified, otherwise relative to the entire timeline
Computed valueA list where each item may be 'normal', a length percentage, or a timeline range name and a length percentage
Animation typeNot animatable

Formal syntax

animation-range-start = 
[ normal | <length-percentage> | <timeline-range-name> <length-percentage>? ]#

<length-percentage> =
<length> |
<percentage>

Examples

Creating a scroll view progress timeline with range start

In this example, the animation-range-end is applied to an element animated via a scroll progress timeline, setting the animation to begin animating well before the element enters the scrollport.

HTML

In the middle of a wall of text, we include an element that we will animate. We added a lot of text in to ensure that our content overflows its container, but this was hidden for the sake of brevity.

html
<div class="animatedElement"></div>

CSS

A scroll progress timeline is defined using setting a scroll() function as the value of the animation-timeline property. This is declared after the animation shorthand, so as to not reset the longhand property value.

An animation-range-start declaration is also set to make the animation start earlier than expected.

css
.animatedElement {
  background-color: deeppink;

  animation: appear 1ms linear;

  animation-timeline: scroll();
  animation-range-start: -25%;
}

@keyframes appear {
  from {
    background-color: rebeccapurple;
    opacity: 0;
    transform: scaleX(0);
  }

  to {
    background-color: darkturquoise;
    opacity: 0.75;
    transform: scaleX(0.75);
  }
}

The other styles were hidden for the sake of brevity.

Result

Scroll to see the element being animated. Note that the element is 25% of the width of it's final state and semi-opaque as it enters the viewprt. This is because the element started animating well before it entered the viewport.

Specifications

Specification
Scroll-driven Animations
# animation-range-start

Browser compatibility

See also