-3

I would like to have some text that when it is over red, it changes to white, and when over grey, it changes to black. This image shows what I want to achieve. The text may go over onto more than one line.

enter image description here

UPDATE: I managed to get it working by using this code to set a gradient text colour:

  color:transparent;
  -webkit-background-clip: text;
  background-clip: text;
  background-image: linear-gradient(
    to right,
    #ffffff 0%,
    #ffffff 50%,
    #000000 50%,
    #000000 100%
  );
Benjamin Sommer
  • 1,058
  • 3
  • 15
  • 35

1 Answers1

0

#red{
background-color:red;
color:white;
}
#grey{
background-color:grey;
color:black;
}
<span id="red">this is my table</span><span id="grey">for students</span>
NFTtray
  • 75
  • 10