Loading by variables

Loading by variables

html

<div class="Loading">
    <i style="--i:0.25;--bg:#2980b9"></i>
    <i style="--i:0.5;--bg:#d35400"></i>
    <i style="--i:0.75;--bg:#c0392b"></i>
    <i style="--i:1;--bg:#27ae60"></i>
    <i style="--i:1.25;--bg:#8e44ad"></i>
</div>

css

body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    box-sizing: border-box;
}

.Loading {
    width: 40px;
    height: 50px;
    display: flex;
    gap: 0 1px;
}

i {
    width: 8px;
    height: 100%;
    background-color: var(--bg);
    transform: scaleY(0);
    animation: Loading 2s linear infinite;
    animation-delay: calc(1s * var(--i));
    transform-origin: bottom;
}

@keyframes Loading {
    0%, 100%{
        transform: scaleY(0);
    }
    50% {
        transform: scaleY(1);
    }
}
مصدر الاكواد