I have some html text and would like to apply some css to do the following to the pixels of the text:
- Apply the Difference Blend Mode with the pixels underneath.
- Apply a Greyscale Filter.
- Apply a Contrast Filter with a very high setting.
This would allow to have UI text elements be positioned over images while still being fairly readable.
I made different attempts, but remained unsuccessful. Here is one where I tried wrapping the text in a container. The blend mode is applied to the actual text element, while the filters are applied to the wrapper:
/* Filters and Blend Mode */
.h1Wrapper {
filter: grayscale(1) contrast(200);
}
h1 {
mix-blend-mode: difference;
color: white;
}
/* SETUP */
.container {
width: 600px;
height: 200px;
position: relative;
}
img {
margin: auto;
display: block;
max-width: 100%;
max-height: 100%;
}
.h1Wrapper {
position: absolute;
top: 0px;
width: 100%;
height: 100%;
}
h1 {
text-align: center;
position: absolute;
top: 0px;
width: 100%;
}
<div class="container">
<img src="https://upload.wikimedia.org/wikipedia/commons/f/f9/Phoenicopterus_ruber_in_S%C3%A3o_Paulo_Zoo.jpg">
<div class="h1Wrapper">
<h1>hello there, good morning, booboo sousa</h1>
</div>
</div>
However, if you run this you can see it did not work. In this case the blend mode seems to be ignored.
When I tried to put the filter and blend mode css both on the h1 element, the filters where both applied before the blend mode, which lead to a different effect that I am trying to achieve.
For clarity, here is a photoshop version of the effect I am trying to achieve: