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

145
Views
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 answers
Answer question

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 Report

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 Report
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!