Is there a CSS property to invert the font-color depending on the background-color like this picture?
font-color
background-color
There is a CSS property called mix-blend-mode, but it's not supported by IE. I recommend using pseudo elements. If you like to support IE6 and IE7 you can also use two DIVs instead of pseudo elements.
.inverted-bar { position: relative; } .inverted-bar:before, .inverted-bar:after { padding: 10px 0; text-indent: 10px; position: absolute; white-space: nowrap; overflow: hidden; content: attr(data-content); } .inverted-bar:before { background-color: aqua; color: red; width: 100%; } .inverted-bar:after { background-color: red; color: aqua; width: 20%; }
<div class="inverted-bar" data-content="Lorem ipsum dolor sit amet"></div>
2.1m questions
2.1m answers
60 comments
57.0k users