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

204
Vistas
How to get each element inside a map and change its CSS?

I want to loop through and assign a custom CSS property to each element inside a map called "item", but I don't know how to do that. Below is my code:

import React from "react";

// Splitting Letters
const SplitText = React.memo(({ str }) => {
  

  const customStyle = {
    position: "absolute",
    /*top: some random top value,*/
    /*left: some random left value,*/
    zIndex: "initial",
    color: "green"
  };

  return (
    <div>
      {str.split("").map((item, index) => {

        
        return (
          <div key={index}>
            {item}
          </div>
        );
      })}
    </div>
  );
});

export default SplitText;

My "item" has a set of letters and I want to catch hold of each letter and somehow map the customStyle CSS property to it.

Any suggestions would be of great help.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

return them with your customStyle


  const customStyle = [{
    position: "absolute",
    /*top: some random top value,*/
    /*left: some random left value,*/
    zIndex: "initial",
    color: "green"
  },{
    position: "relative",
    /*top: some random top value,*/
    /*left: some random left value,*/
    zIndex: "1",
    color: "red"
  }];

 return (
          <div key={index} style={customStyle[index]}>
            {item}
          </div>
        );
about 4 years ago · Juan Pablo Isaza Denunciar
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