Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda