Skip to content

Instantly share code, notes, and snippets.

@LeoSeyers
Last active March 17, 2023 17:37
Show Gist options
  • Save LeoSeyers/4e5b94d7a22ce87cc28065992ae312f6 to your computer and use it in GitHub Desktop.
Save LeoSeyers/4e5b94d7a22ce87cc28065992ae312f6 to your computer and use it in GitHub Desktop.
Marquee Component
@keyframes marquee {
0% {
transform: translateX(0);
}
100% {
transform: translateX(var(--offset));
}
}
.c-marquee {
--scrolling-speed: 2s;
--offset: -50%;
display: flex;
width: 100%;
overflow: hidden;
@include max-width(tab-lg) {
align-items: center;
height: var(--c-header);
}
span {
position: relative;
width: fit-content;
padding-right: var(--padding);
white-space: nowrap;
}
&:not(.is-enabled) span {
animation: marquee var(--scrolling-speed) linear infinite;
}
&__inner {
position: relative;
display: flex;
align-items: center;
width: fit-content;
transition: opacity 1s;
will-change: transform;
span {
width: fit-content;
white-space: nowrap;
&::after {
margin-left: var(--padding);
content: "· ";
}
}
}
}
@LeoSeyers
Copy link
Author

LeoSeyers commented Mar 1, 2023

<div class="c-marquee">
        <div class="c-marquee__inner">
            <span></span>
            <span></span>
            <span></span>
          </div>
    </div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment