Text blended over background color

You can create another gradient to color the text without the use of mix-blend mode:

.container {
  width: 200px;
  height: 20px;
  background: linear-gradient(to right, #43a047 50%, #eee 0);
  text-align: center;
}

.text {
  background: linear-gradient(to right, white 50%, black 0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-weight: bold;
}
<div class="container">
  <div class="text">Some text here</div>
</div>

And for better flexibility you can use CSS variable to control the progress:

.container {
  width: 200px;
  height: 20px;
  margin:5px;
  background: linear-gradient(to right, #43a047 var(--p,50%), #eee 0);
  text-align: center;
}

.text {
  background: linear-gradient(to right, white var(--p,50%), black 0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-weight: bold;
}
<div class="container" style="--p:80%">
  <div class="text">Some text here</div>
</div>

<div class="container" style="--p:20%">
  <div class="text">Some text here</div>
</div>
<div class="container">
  <div class="text">Some text here</div>
</div>

Leave a Comment