Skip to content

Instantly share code, notes, and snippets.

@distransient
Created June 22, 2016 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save distransient/f1858d1e954b27047623c0031d3da52e to your computer and use it in GitHub Desktop.
Save distransient/f1858d1e954b27047623c0031d3da52e to your computer and use it in GitHub Desktop.
Sibilant Carousel Example

This is a simple carousel implemented in normal javascript and sibilant (lisp) javascript.

You can read more about Sibilant here!

<!doctype html>
<html>
<head>
<title>Sibilant Carousel Demo</title>
<meta charset="utf-8">
<style>
html, body { height: 100% }
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
}
[data-carousel] {
width: 50em;
max-width: 100vw;
height: 40em;
max-height: 100vh;
overflow: hidden;
position: relative;
}
[data-carousel-slide] {
position: absolute;
top: 0;
left: 0;
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
border-radius: 1em;
transition: visibility 2s, opacity 2s;
}
/* allow transition to fade between items */
[data-carousel-slide][hidden] {
display: block !important;
opacity: 0;
}
/* make img behave like background-size: cover */
[data-carousel-slide] img {
position: absolute;
min-width: 100%;
min-height: 100%;
width: 100%;
height: auto;
}
[data-carousel-slide] figcaption {
box-sizing: border-box;
position: absolute;
width: 100%;
height: 100%;
font-size: 5em;
padding: 1em;
color: white;
}
</style>
</head>
<body>
<section data-carousel>
<figure data-carousel-slide>
<img src="https://upload.wikimedia.org/wikipedia/commons/5/50/A_beautiful_stray_cat.jpg">
<figcaption>Lorem ipsum</figcaption>
</figure>
<figure hidden data-carousel-slide>
<img src="https://upload.wikimedia.org/wikipedia/commons/1/1a/Be_togeather.jpg">
<figcaption>dolor sit amet</figcaption>
</figure>
<figure hidden data-carousel-slide>
<img src="https://upload.wikimedia.org/wikipedia/commons/e/ef/Cats_-_Kediler_04.jpg">
<figcaption>consectetur adipiscing elit</figcaption>
</figure>
</nav>
<script src="./carousel.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment