Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

html - Change text color if background image is not white?

I have read a lot articles about this but haven't found anything to solve my problem.

Is it possible somehow to change text color based on background image with Jquery or/and CSS?

I have to make a responsive website with this requested, but got stuck.

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

An idea is to color the text with an inverted background.

Here is an idea considering radial-gradient:

.box {
  padding: 50px;
  background: radial-gradient(circle at 70% 0px, #fff 45%, purple 45.5%) fixed;
}

p {
  font-size: 25px;
  font-weight: bold;
  /*Should be the same background but inverted color*/
  background: radial-gradient(circle at 70% 0px, purple 45%, #fff 45.5%) fixed;
  background-clip: text;
  color: transparent;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
<div class="box">
  <p>Some text here Some text here Some text here Some text here </p>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...