An experiment in cleaning up CSS by just avoiding dis-features and focusing on flexbox and CSS grids.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
fsckcss/src/demos/Carousel.svelte

95 lines
1.8 KiB

<script>
import { link } from 'svelte-spa-router';
import Icon from '../components/Icon.svelte';
import { holder } from '../../lib/imgholder.js';
import CodeView from '../components/CodeView.svelte';
let images = [1,2,3,4,5,6,7];
</script>
<style>
content {
border: 1px solid #ddd;
display: flex;
flex-direction: column;
flex: flex-grow;
padding: 1rem;
}
carousel {
outline: 2px solid green;
position: relative;
}
carousel figure {
display: none;
}
carousel figure.active {
display: flex;
position: relative;
flex-direction: column;
outline: 1px solid red;
}
carousel figure img {
width: 100%;
}
carousel figure figcaption {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
text-align: center;
font-size: 2em;
background: var(--color-bg-secondary);
opacity: 0%;
}
carousel figure figcaption:hover {
opacity: 90%;
}
carousel next,prev {
position: absolute;
bottom: 0;
opacity: 0%;
height: 100%;
display: flex;
flex-direction: column;
align-content: center;
justify-content: center;
}
carousel next {
right: 0;
}
carousel prev {
left: 0;
}
carousel next:hover,prev:hover {
opacity: 60%;
background-color: var(--color-bg);
}
</style>
<content>
<h1>Carousel</h1>
<carousel>
{#each images as image}
<figure class:active={ image === 1 }>
<img alt="Stock photo" src="{ holder(16 * 40,9 * 40) }">
<figcaption>Image #{image}</figcaption>
</figure>
{/each}
<prev><Icon name="arrow-left" size="48" /></prev>
<next><Icon name="arrow-right" size="48" /></next>
</carousel>
</content>
<CodeView source="/code/Carousel" notes="/code/Carousel.notes.html" />