Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
How to show marquee function loop for each array and show complete value?

I'm coding marquee function and I wanna show the data array. I want it to show single value on marquee also currently I hardcode the animation time but I wanna use the variable instead of calculating the animation delay time(1.66, 3.33).

What I achieved now: Show 2 values on marquee on the same time

Codesandbox

JS:

import styles from "../styles/Page1.module.css";

function Marquee(props) {
    return props.data.map((data) => (
        <p key={data.key} style={{ "animation-delay": `${data.delay}s` }}>
            {data.data}
        </p>
    ));
}

export default function Page1() {
    const data = [
        {
            data: "cosmopolitan", //(Triple sec + vodka + lime juice + cranberry juice)
            key: "1",
            delay: "0",
        },
        {
            data: "screwdriver", //(orange juice + vodka)
            key: "2",
            delay: "1.66",
        },
        ,
        {
            data: "Mojito",
            key: "3",
            delay: "3.33",
        },
    ];
    return (
        <div className={styles.marquee}>
            <Marquee data={data} />
        </div>
    );
}

CSS:

.marquee {
    height: 30px;
    overflow: hidden;
    position: relative;
    background: #fefefe;
    color: #333;
    border: 1px solid #4a4a4a;
}

.marquee p {
    position: absolute;
    width: 100%;
    height: 100%;
    margin: 0;
    line-height: 30px;
    text-align: left;
    transform: translateX(100%);
    /* animation: scroll-left 20s linear infinite;  */
    animation-name: scroll-left;
    animation-duration: 5s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

@keyframes scroll-left {
    0% {
        transform: translateX(100%);
    }
    100% {
        transform: translateX(-100%);
    }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!