- Nice cat number 1
  adopt me
- Nice cat number 2
  adopt me
- Nice cat number 3
  adopt me
- Nice cat number 4
  adopt me
- Nice cat number 5
  adopt me
- Nice cat number 6
  adopt me
- Nice cat number 7
  adopt me
- Nice cat number 8
  adopt me

‹
›

## Technique

The above is an unordened list with horizontal overflow set to auto, snap scrolling and hidden scrollbars. You can swipe the carousel with your finger on touch screens through native touch scroll. You can use the arrow keys on your keyboard to scroll the carousel (when the carousel has focus). The bullets are actually anchor links, which trigger a 'scroll-behaviour: smooth' scroll. The script uses a simple setInterval for autoplay which does not fire during hover and can be set on the carousel div in a custom attribute in milliseconds. Also checkout the Carousel with CSS scroll snap .

## Browser compatibility

The code is tested on the newest versions of Chrome, Firefox, Chrome mobile and Firefox mobile in april 2021. This code uses fairly new techniques, like scroll snapping. However, I expect this solution to degrade quite graceful. It even looks and works 'okay-ish' without javascript.

## About the author

I am a website performance expert and for a project I was looking for a touch enabled carousel . I could not find one that was minimal, so I created a basic responsive and touch-enabled carousel that weighs only 3kb (uncompressed and including CSS). This carousel is based on modern web technology and will not slow down (the rendering of) your page... and yes, that project link is a link to a production website.

## Credits

The approach is (partly) based on the 2019 scroll snap carousel from Nolan Lawson . The debounce function is written by Chris Ferdinandi . The cat images are borrowed from Pexels .

## License

WTFPL - This is a GPL-compatible permissive license most commonly used as a free software license. As a public domain like license, the WTFPL is essentially the same as dedication to the public domain. It allows redistribution and modification of the work under any terms. The title is an abbreviation of "Do What The Fuck You Want To Public License".

Enjoy the code!
Joost van der Schee