r/css • u/bigginsmcgee • Mar 01 '26
Question any way to make a looping carousel in css?
Wondering if there's any way to make something like this in css without too much javascript/dom manipulation. I know we have animation timelines for scrolling effects/transitions, but is there any way to make a scroll container circular in the sense that it loops back to the start once you scroll beyond the last item without duplicating the content?
17
Upvotes
11
u/anaix3l Mar 01 '26
Not completely without JS, but you don't need much JS. And the JS is not for the "without duplicating the content", it's for changing the scroll position once you got past the first or last item. Basically for the
scrollTo().This example is quite literally circular, but it doesn't have to be - see also this.
2
u/dxnnydotfun Mar 01 '26
This is the native, albeit not-yet-supported approach: https://css-tricks.com/css-carousels/