Menu

A Snap-Scrolling Vertical Video Feed with CSS and IntersectionObserver
📰

A Snap-Scrolling Vertical Video Feed with CSS and IntersectionObserver

DEV Community: frontend·Tiktkviewer·9 days ago
#PkX2rrX6
#devtofrontend#devto#dev#feed#const
Long article (768 words) — no AI summary yet.
Reading 0:00
15s threshold

Short-video apps all share one interaction: a full-screen vertical feed where each swipe snaps to the next video and only the visible one plays. You can build that feel on the web with CSS scroll snapping and an IntersectionObserver , no framework needed. This post walks through a version that also works with the keyboard and respects reduced-motion settings.

The markup

<main class = "feed" tabindex = "0" aria-label = "Video feed" > <section class = "item" ><video src = "clip1.mp4" muted loop playsinline preload = "metadata" ></video></section> <section class = "item" ><video src = "clip2.mp4" muted loop playsinline preload = "metadata" ></video></section> <section class = "item" ><video src = "clip3.mp4" muted loop playsinline preload = "metadata" ></video></section> </main>

Enter fullscreen mode

Exit fullscreen mode

muted and playsinline matter: mobile browsers only allow autoplay for muted, inline video.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.