Files

212 lines
6.0 KiB
HTML
Raw Permalink Normal View History

2026-10-02 15:55:28 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
2026-10-03 21:24:35 +02:00
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description"
content="Snappy Carousel Demo – Snappy is a lightweight carousel. Mostly CSS-only, with some Javascript for navigation and drag support." />
2026-10-02 15:55:28 +02:00
<title>Snappy</title>
2026-10-03 21:24:35 +02:00
<link rel="stylesheet" href="dist/snappy.css">
2026-10-02 15:55:28 +02:00
<style>
html,
body {
/* Transitional from https://modernfontstacks.com/ */
font-family: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif;
font-weight: normal;
font-size: 1.25rem;
background-color: #f8f9fa;
color: #343a40;
@media (prefers-color-scheme: dark) {
background-color: #212529;
color: #f8f9fa;
}
}
body {
2026-10-05 09:53:44 +02:00
padding: 2rem;
max-width: 960px;
margin: auto;
margin-bottom: 1000px;
2026-10-02 15:55:28 +02:00
}
h1 {
font-size: 3rem;
margin-bottom: 1em;
}
/* Custom snappy styling */
/* Colors from Open color (https://yeun.github.io/open-color) */
2026-10-02 15:55:28 +02:00
.snappy-carousel {
2026-10-03 21:24:35 +02:00
margin-bottom: 2rem;
.scroll-container {
2026-10-03 21:24:35 +02:00
max-height: 420px;
2026-10-02 21:46:43 +02:00
gap: 0.5rem;
2026-10-02 15:55:28 +02:00
}
.slide {
display: flex;
justify-content: center;
align-items: center;
aspect-ratio: 3/2;
2026-10-05 09:53:44 +02:00
height: 350px;
max-width: 75%;
2026-10-02 21:46:43 +02:00
border-radius: 1rem;
border: 1px solid #ced4da;
2026-10-02 15:55:28 +02:00
2026-10-05 09:53:44 +02:00
background-color: #ffd8a8;
color: #343a40;
2026-10-02 21:46:43 +02:00
transition: box-shadow 0.8s cubic-bezier(0.25, 1, 0.5, 1);
2026-10-02 15:55:28 +02:00
@media (prefers-color-scheme: dark) {
background-color: #495057;
color: #f8f9fa;
2026-10-02 21:46:43 +02:00
border-color: #868e96;
}
}
2026-10-02 15:55:28 +02:00
2026-10-05 09:53:44 +02:00
&[data-scroll-direction="y"] .slide {
max-width: initial;
height: 150px;
}
.slide:nth-child(even) {
2026-10-05 09:53:44 +02:00
background-color: #e5dbff;
2026-10-02 15:55:28 +02:00
@media (prefers-color-scheme: dark) {
background-color: #343a40;
color: #f8f9fa;
}
2026-10-02 15:55:28 +02:00
}
2026-10-02 21:46:43 +02:00
.slide.is-active {
box-shadow: inset 0 0 0 4px #339af0;
}
.prev,
.next {
width: 1.5rem;
height: 1.5rem;
font-size: 1rem;
border: none;
background-color: #f1f3f5;
color: #339af0;
2026-10-02 15:55:28 +02:00
&:hover,
&:active {
background-color: #dee2e6;
}
@media (prefers-color-scheme: dark) {
background-color: #495057;
&:hover,
&:active {
background-color: #868e96;
color: #1971c2;
}
2026-10-02 15:55:28 +02:00
}
}
2026-10-03 21:24:35 +02:00
.prev:disabled,
.next:disabled {
opacity: 0.5;
}
.pagination {
2026-10-02 21:46:43 +02:00
display: inline-flex;
margin-top: 1rem;
}
2026-10-02 15:55:28 +02:00
.pagination .dot {
2026-10-03 21:24:35 +02:00
border-radius: 1lh;
background-color: #dee2e6 !important;
margin: 0 0.25rem;
2026-10-02 15:55:28 +02:00
transition-property: width, background;
transition-duration: .8s;
transition-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
2026-10-02 15:55:28 +02:00
cursor: pointer;
}
2026-10-02 15:55:28 +02:00
.pagination .dot:hover {
background-color: #adb5bd !important;
}
2026-10-02 15:55:28 +02:00
.pagination .dot.is-active {
background-color: #1971c2 !important;
width: 2rem !important;
}
2026-10-02 15:55:28 +02:00
}
</style>
</head>
<body>
2026-10-03 21:24:35 +02:00
<header>
<h1>Snappy</h1>
</header>
2026-10-02 15:55:28 +02:00
2026-10-03 21:24:35 +02:00
<main>
2026-10-02 15:55:28 +02:00
2026-10-03 21:24:35 +02:00
<!--
2026-10-02 15:55:28 +02:00
Options
-------
2026-10-02 21:46:43 +02:00
See https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Scroll_snap
2026-10-02 15:55:28 +02:00
data-scroll-direction="x"
data-scroll-direction="y"
2026-10-02 15:55:28 +02:00
data-snap-stop="always"
data-snap-stop="normal"
data-snap-align="center"
data-snap-align="start"
data-snap-align="end"
2026-10-03 21:24:35 +02:00
-->
<section class="snappy-carousel" aria-labelledby="horizontal-carousel-heading">
<h2 id="horizontal-carousel-heading" class="visuallyhidden">Horizontal</h2>
<ul class="scroll-container">
<li class="slide">1</li>
<li class="slide">2</li>
<li class="slide">3</li>
<li class="slide">4</li>
<li class="slide">5</li>
<li class="slide">6</li>
<li class="slide">7</li>
<li class="slide">8</li>
</ul>
<button class="prev">❮</button>
<button class="next">❯</button>
<ul class="pagination"></ul>
</section>
<section class="snappy-carousel" data-scroll-direction="y" aria-labelledby="horizontal-carousel-heading">
<h2 id="horizontal-carousel-heading" class="visuallyhidden">Vertical</h2>
<ul class="scroll-container">
<li class="slide">1</li>
<li class="slide">2</li>
<li class="slide">3</li>
<li class="slide">4</li>
<li class="slide">5</li>
<li class="slide">6</li>
<li class="slide">7</li>
<li class="slide">8</li>
</ul>
<button class="prev">❮</button>
<button class="next">❯</button>
<ul class="pagination"></ul>
</section>
</main>
2026-10-02 15:55:28 +02:00
<!-- Javascript is only needed for pagination and buttons -->
<script src="dist/snappy.js" defer></script>
</body>
</html>