Spec-Zone.ru › CSS

`animation-range-start` CSS property

Baseline 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 sets the point on the timeline where an animation should start.

Syntax

/* 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;

/* Multiple values */
animation-range-start:
  cover 20%,
  contain 100px;

/* Global values */
animation-range-start: inherit;
animation-range-start: initial;
animation-range-start: revert;
animation-range-start: revert-layer;
animation-range-start: unset;

Values

This property is specified as a comma-separated list of values. Each value can be one of the following:

normal
Represents the start of the timeline. This is the default value.
<length-percentage>
Specifies a length or percentage value measured from the beginning of the timeline.
<timeline-range-name>
Specifies a named timeline range within the overall timeline. The range starts at 0%.
<timeline-range-name> <length-percentage>
Specifies a length or percentage value measured from the beginning of the specified named timeline range.

Description

Allowed values for the animation-range-start property are normal, a <length-percentage>, a <timeline-range-name>, or a <timeline-range-name> followed by a <length-percentage>. If the <timeline-range-name> value does not include a <length-percentage>, the percentage defaults to 0%.

See animation-range for a detailed description of the available values.

When specifying multiple comma-separated values, they apply to the animations in the order in which the animation-name values appear. See Setting multiple animation property values.

The animation-range-start is included in the animation shorthand as a reset-only value. This means that using the animation shorthand resets any previously declared animation-range-start value of equal or lower specificity to normal; the shorthand cannot be used to set a new animation-range-start value. When creating CSS scroll-driven animations, you should declare animation-range-start after declaring any animation shorthand to avoid resetting the value to normal.

The animation-range-start, along with the animation-range-end property, can also be set using the animation-range shorthand.

Formal definition

Initial value normal
Applies to all elements
Inherited no
Percentages Relative to the specified named timeline range if specified, otherwise relative to the entire timeline
Computed value A list where each item may be 'normal', a length percentage, or a timeline range name and a length percentage
Animation type Not animatable

Formal syntax

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

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

<timeline-range-name> = 
  cover |
  contain |
  entry |
  exit |
  entry-crossing |
  exit-crossing

Examples

Creating a scroll progress timeline with range start

In this example, the animation-range-start is applied to an element animated via a scroll progress timeline. This makes the animation start well before the element enters the scrollport.

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>

In the middle of a long block of text, we've included an element that we'll animate. We've added a lot of text to ensure that the content overflows its container; the extra text is hidden here for brevity.

<div class="animatedElement"></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

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 to avoid resetting the longhand property value.

We've also set animation-range-start to make the animation start earlier than expected.

.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);
  }
}

Other styles applied in this example have been hidden here for brevity.

.animatedElement {
  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;
}

@supports not (animation-range-start: normal) {
  body::before {
    content: "Your browser does not support the 'animation-range-start' property.";
    color: black;
    background-color: wheat;
    display: block;
    text-align: center;
    padding: 1rem 0;
  }
}

Result

Scroll to see the element animate. Notice how the element is already scaled and semi-opaque as it enters the viewport. This is because the element started animating well before it entered the viewport.

Specifications

Specification
Scroll-driven Animations
# animation-range-start

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on iOS Samsung Internet WebView Android WebView on iOS
animation-range-start
115
115
preview
101
26
115
No
77
26
23.0
115
26
normal
115
115
preview
101
26
115
No
77
26
23.0
115
26

See also

  • animation-timeline
  • animation-range
  • animation-range-end
  • view-timeline-inset
  • Element.animate() rangeStart property
  • Scroll-driven animation timelines
  • Understanding timeline range names
  • CSS scroll-driven animations module
  • View progress timeline: Ranges and animation progress visualizer

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/animation-range-start

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API