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

149
Vistas
Why are my css classes not working in my React project?

For this one part I am trying to change the color of the text based on the character index, but the styling just is not working.

import "../stylesheets/TypingTest.css"

const TypingTest = (props) => {
  return (
    <div>
      <div>
        {props.words.split("").map(function (char, idx) {
          return (
            <span className={props.index === idx ? "right" : "wrong"}>
              {char}
            </span>
          );
        })}
        <div>{props.index}</div>
      </div>
    </div>
  );
};

export default TypingTest;
.right{
    color: var(red);
}
.wrong{
    color: var(green);
}

Also to note, if I take the logic out of the so it becomes className='right' it still does not work

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

0

Because your css is wrong:

.right {
    color: var(red); <--- you are try to use a css variable.
}
.wrong {
    color: var(green); <--- you are try to use a css variable.
}

I you want to use css variables you can define:

--red: red;
--green: green:

.right {
    color: var(--red);
}
.wrong {
    color: var(--green);
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Should it not be

var(--red)

And

var(--green)

https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties

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