1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-10-23 18:56:29 +02:00
Files
csslayout/contents/slider.md
2022-09-21 14:31:37 +07:00

1.0 KiB

layout, title, description, keywords
layout title description keywords
layouts/post.njk Slider Create a slider with CSS flexbox css flexbox, css slider

HTML

<div class="slider">
    <!-- Left side -->
    <!-- Width based on the current value -->
    <div class="slider__left" style="width: 20%"></div>

    <!-- Circle -->
    <div class="slider__circle"></div>

    <!-- Right side -->
    <div class="slider__right"></div>
</div>

CSS

.slider {
    /* Content is centered horizontally */
    align-items: center;
    display: flex;

    /* Size */
    height: 2rem;
}

.slider__left {
    height: 2px;

    /* Colors */
    background-color: #d1d5db;
}

.slider__circle {
    /* Size */
    height: 2rem;
    width: 2rem;

    /* Rounded border */
    border-radius: 9999px;

    /* Colors */
    background-color: #3b82f6;
}

.slider__right {
    /* Take the remaining width */
    flex: 1;
    height: 2px;

    /* Colors */
    background-color: #d1d5db;
}

{% demo %}{% include "covers/slider.njk" %}{% enddemo %}