Change text color based on brightness of the covered background area?

前端 未结 8 1587
悲哀的现实
悲哀的现实 2020-11-27 09:53

I\'ve thought about the following for a while already, so now I want to know your opinions, possible solutions, and so on.

I am looking for a plugin or technique tha

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 10:08

    mix-blend-mode does the trick:

    header {
      overflow: hidden;
      height: 100vh;
      background: url(https://www.w3schools.com/html/pic_mountain.jpg) 50%/cover;
    }
    
    h2 {
      color: white;
      font: 900 35vmin/50vh arial;
      text-align: center;
      mix-blend-mode: difference;
      filter: drop-shadow(0.05em 0.05em orange);
    }

    Edit me here

    Addition (March 2018): Following, a nice tutorial explaining all different types of modes/implementations: https://css-tricks.com/css-techniques-and-effects-for-knockout-text/

提交回复
热议问题