ScrollPremium

Rotate on Scroll

A 100 px tile and the icon it carries make two full turns while the area scrolls from top to bottom: a quarter turn every 65 px, one turn at mid-scroll. A single rule, animation-timeline: scroll(), on a whole block — no JavaScript, and everything runs backwards when you scroll up.

CSSRotateScroll

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Scroll has 74 effects, including 12 free. Explore the category →

3 usage examples

The wheel that follows the stages of a cycle route — a tourist office page — Rotate on Scroll example 1

① The wheel that follows the stages of a cycle route — a tourist office page

WhenPresentation page of a five-stage cycling itinerary. In the left margin a dashed line stands for the road; a wheel stays hooked to it while the stage cards climb on the right.
WhyThe wheel makes scrolling feel like moving along the road: it turns as you go down, stops while you read a stage, rolls back if you scroll up. And the sum is exact: two turns of a 70 px wheel cover 440 px of circumference, precisely the travel of the area — it rolls on the dashed line without slipping.
SettingsTile turned into a wheel: 70 px, border-radius: 50%, background removed, 7 px border, SVG replaced by eight spokes and a red valve. It is pinned by the scene (position: sticky; top: 121px, tray on align-items: flex-start). A 540 × 312 px area, 752 px tray: 440 px of travel. Capture: scrolling at 88 px/s by a timer in the scene.
Turning the sheet a quarter turn at each fold — an origami tutorial — Rotate on Scroll example 2

② Turning the sheet a quarter turn at each fold — an origami tutorial

WhenTutorial for the paper fortune teller: eight corners to bring to the centre. The drawn sheet on the left, the instruction for the current fold on the right; the “Next fold” button moves to the following instruction.
WhyThe move is the same eight times, provided you turn the sheet between folds: the corner to fold always comes back to the bottom right. The sheet on screen makes that quarter turn at each click, corner numbers included, and the learner keeps theirs the same way round as the model. Eight quarter turns are the animation's two turns, with nothing to tune.
SettingsTile enlarged to 150 px, paper background, SVG replaced by the creases and four numbered corners; pinned by the scene (position: sticky; top: 41px). A 498 × 232 px area and nine 232 px instructions: 1,856 px of travel, one click = 232 px = 90°. The button scrolls by one notch (a script in the scene, yours to write), eased by the code's scroll-behavior: smooth. In the capture a timer clicks every 1.35 s. The sheet turns; it does not fold.
Row counter of a knitting pattern — the ball of yarn turns in the header — Rotate on Scroll example 3

③ Row counter of a knitting pattern — the ball of yarn turns in the header

WhenA beanie pattern read on a phone, knitting in hand: the pattern's sixty-four rows in eighteen lines, a header that stays on top with the pattern's name.
WhyWhen you put the needles down to scroll, you want to find your place at a glance. The little ball in the header unwinds as the rows go by — two turns between casting on and closing — and winds back if you scroll up: a progress marker that fits in 34 px.
SettingsTile shrunk to 34 px, round, coral gradient, SVG replaced by five strands of yarn. It is no longer alone in the tray: the scene puts it in a 54 px header on position: sticky; top: 0, followed by the list of rows. A 190 × 318 px area, 586 px of travel, i.e. 1.2° per pixel. Capture: 92 px/s, timer in the scene.

How it works

The animated element is .sb-rotscroll-shape: a 100 px square with 16 px corners, an indigo → fuchsia gradient, centring a 40 px SVG. It gets @keyframes fx0549Rotate, a single keyframe, to { transform: rotate(720deg) }, and the declaration animation-timeline: scroll(). With no argument, scroll() means the first scrolling area above the tile: the animation's progress becomes that area's position, 0% at the top, 100% at the bottom. Because the rotation is set on the block and not on a stroke drawn inside it, everything it holds turns with it — icon, background, a shadow if you add one.

In the demo the area is 280 px tall and the .sb-rotscroll-content tray 800: 520 px of travel for 720°, i.e. 1.385° per pixel. Read in Chromium 149 and WebKit 26.5: 138° at 100 px, 360° (tile upright again) at 260 px, 554° at 400 px, 720° at the end stop; both engines return the same matrix. Interpolation is linear: the tile turns at the speed of the gesture, stops with it, runs backwards when you scroll up. The tile sits in the flow, in the middle of the tray: it crosses the frame from bottom to top. You see it from 68 to 452 px of scrolling, whole from 183 to 337 px — so about 530° of the 720° pass before your eyes, and the frame is empty when it opens and at the end, where only the caption comes in (at 487 px).

The original animation was left alone; what surrounds it was repaired. Selectors hang from .fx-0549-root and the animation is renamed fx0549Rotate: the catalogue holds another effect with almost the same name that shares the area's classes, and both now live on one page. The area gains overflow-x: hidden — a turning square sweeps its diagonal, 141 px, and used to open a horizontal bar in a narrower column. Added as well: keyboard focus, the reduced-motion rule, and a readable caption (white at 60% instead of 30%).

Accessibility

  • Reduced motion: two full turns of an object while you read is exactly what the system setting asks to avoid. Under prefers-reduced-motion: reduce the animation is removed: the tile stays upright and scrolls with the content like a picture. The hint stops pulsing and scroll jumps are no longer smoothed.
  • Tile content: put nothing that must be read inside a turning block — a figure or a word is upside down half the time. The SVG carries aria-hidden="true"; if it means something (a logo, a state), give that meaning as text next to it. The .sb-rotscroll-label caption does not turn and is read normally.
  • Keyboard: the area is reachable with Tab (tabindex="0", role="region", a name to adapt) and shows a violet outline; each arrow press scrolls 40 px in Chromium, i.e. 55° of rotation. Recorded in Chromium, Firefox and WebKit — the last one skipped the area in the original code.
  • Contrast and touch: the icon's white stroke reaches 4.5:1 on the indigo side of the tile and 3.5:1 on the fuchsia side (computed); the tile itself stands at 4.4:1 from the background. With a finger the area scrolls natively (150 px swiped, 151 px recorded in touch emulation). On a phone, scroll inertia should carry the rotation on after release: expected, but not verified on a device.

Browser compatibility

CSS only: the floor is that of animation-timeline: scroll() — Chrome and Edge 115, Safari 26, Firefox 159 according to MDN. Identical angles in Chromium 149 and WebKit 26.5 at the four positions recorded. Firefox 151 does not read the rule: the tile stays upright, visible, and crosses the frame without turning. No JavaScript fallback is supplied for that case. Still to be tried: Firefox 159 and later, Safari on a Mac and on an iPhone.

Chrome 115+✓ Full (measured in Chromium 149)
Edge 115+✓ Not verified (same engine as Chrome)
Safari 26+✓ Full in the WebKit 26.5 test build; real Safari not verified
Firefox 159+✓ Not verified (support announced by MDN)
Firefox up to 158✓ Upright tile, no rotation (measured in Firefox 151)
iOS 26+ / Android Chrome 115+✓ Not verified on a device

The rotation is declared inside @supports (animation-timeline: scroll()). A browser that fails that test shows the tile at 0°, its icon the right way up: the object stays, the motion is missing. If the rotation means something on your page (a step, a direction), provide that meaning another way for those visitors.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0549-root">
  <div class="sdc-scroll-container" tabindex="0" role="region" aria-label="…">
    <div class="sb-rotscroll-content">
      <div class="sb-rotscroll-shape">
        <svg viewBox="0 0 24 24" aria-hidden="true">…</svg>
      </div>
      <span class="sb-rotscroll-label">…</span>
    </div>
  </div>
  <span class="sdc-scroll-hint" aria-hidden="true">…</span>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Total angle (CSS — @keyframes fx0549Rotate { to { transform: rotate(720deg) } }) 720°, two turns 360° for a single turn, 90° for a quarter, a negative value to turn the other way. For a wheel of diameter d to look as if it rolls: angle = travel × 360 ÷ (π × d).
Tile (CSS — .sb-rotscroll-shape: width, height, border-radius, background) 100 × 100 px, 16 px corners, gradient #6366f1 → #d946ef border-radius: 50% gives a disc: the rotation then only shows through what it contains. A tile of side c sweeps c × 1.41 in width.
Icon (HTML — the svg; CSS — .sb-rotscroll-shape svg) three stacked diamonds, 40 px, white 1.5 stroke Replace it with your drawing or an image. A shape with no symmetry (arrow, letter, valve) makes each quarter turn readable; a symmetrical one looks still.
Tile position (CSS — .sb-rotscroll-content { align-items: center }) middle of the tray, in the flow To keep it in view for the whole travel: align-items: flex-start on the tray, then position: sticky; top: 90px; margin-top: 90px on the tile.
Travel (CSS — .sb-rotscroll-content { height: 800px }, .sdc-scroll-container { height: 280px }) 800 − 280 = 520 px, i.e. 1.385° per pixel Rotation speed is the angle divided by the travel. With no height and no overflow-y on the area, the whole page turns the tile.
Caption and hint (HTML — .sb-rotscroll-label, .sdc-scroll-hint) a sentence at the bottom of the tray, “Scroll ↓” over the frame Two demo texts, to delete or rewrite. The caption only shows over the last 33 pixels of the travel.

FAQ

All three turn by 720°, but not the same thing. Rotation on Scroll is an instrument: a pinned dial with twelve ticks where only the needle turns, on a named timeline, with a script for Firefox — you read a position on it. Nested Rotation on Scroll nests three rotations, a square and two dashed frames at different speeds. This one is the simplest of the three: a whole block, icon included, one rule, no script. It is the one to take for turning an object of your own — a wheel, a logo, an illustration.
Because the tile sits in the middle of an 800 px tray and the frame only shows 280 of them: it comes in after 68 px of scrolling and leaves at 452 px. That is how an object placed in a page behaves, met on the way down. For a tile that is always visible, pin it: align-items: flex-start on .sb-rotscroll-content, position: sticky; top: 90px; margin-top: 90px on .sb-rotscroll-shape. Two of the three examples above do so.
The animation is continuous; it is the stops of the scroll that make notches. Cut the content into sections of equal height and bring them one by one — with buttons, as in the origami example, or with scroll-snap-type: y mandatory on the area and scroll-snap-align: start on each section (a lead not tried here). Eight equal sections give eight quarter turns: the travel is then eight area heights, and each stop falls on a multiple of 90°.