Files
Snappy-Carousel/index.html
T

191 lines
5.2 KiB
HTML
Raw Normal View History

2026-10-02 15:55:28 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Snappy</title>
<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 {
margin: 2rem;
}
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 {
.scroll-container {
max-height: 400px;
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;
2026-10-02 21:46:43 +02:00
width: 75%;
aspect-ratio: 3/2;
2026-10-02 21:46:43 +02:00
min-height: 200px;
max-height: 400px;
2026-10-02 21:46:43 +02:00
border-radius: 1rem;
border: 1px solid #ced4da;
2026-10-02 15:55:28 +02:00
background-color: #f1f3f5;
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
.slide:nth-child(even) {
background-color: #e9ecef;
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
}
}
.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 {
width: 0.66rem !important;
height: 0.66rem !important;
border-radius: 0.33rem;
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>
<link rel="stylesheet" href="dist/snappy.css">
</head>
<body>
<h1>Snappy</h1>
<!--
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-02 21:46:43 +02:00
<div class="snappy-carousel">
<div class="scroll-container">
<div class="slide">1</div>
<div class="slide">2</div>
<div class="slide">3</div>
<div class="slide">4</div>
<div class="slide">5</div>
<div class="slide">6</div>
<div class="slide">7</div>
<div class="slide">8</div>
</div>
<button class="prev">❮</button>
<button class="next">❯</button>
<div class="pagination"></div>
2026-10-02 15:55:28 +02:00
</div>
<div class="snappy-carousel" data-scroll-direction="y">
<div class="scroll-container">
<div class="slide">1</div>
<div class="slide">2</div>
<div class="slide">3</div>
<div class="slide">4</div>
<div class="slide">5</div>
<div class="slide">6</div>
<div class="slide">7</div>
<div class="slide">8</div>
</div>
<button class="prev">❮</button>
<button class="next">❯</button>
<div class="pagination"></div>
</div>
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>