Created
November 15, 2022 02:48
-
-
Save jonrandy/ec90633bd0585c4f6e3a86736c5ce453 to your computer and use it in GitHub Desktop.
Carousel without JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<g-carousel> | |
<g-images> | |
<a href="#b"><img id="a" src="https://source.unsplash.com/random/800x400?sig=1"></a> | |
<a href="#c"><img id="b" src="https://source.unsplash.com/random/800x400?sig=2"></a> | |
<a href="#a"><img id="c" src="https://source.unsplash.com/random/800x400?sig=3"></a> | |
</g-images> | |
</g-carousel> | |
<style> | |
g-carousel { | |
display: block; | |
width: 100%; | |
overflow-x: scroll; | |
scroll-snap-type: x mandatory; | |
scroll-behavior: smooth; | |
} | |
a { | |
display: contents; | |
} | |
g-images { | |
display: flex; | |
width: calc(100% * 3); | |
} | |
img { | |
width: 100%; | |
scroll-snap-align: center; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment