I am struggling with making a black text element overlap a black div while ensuring that the overlapping part of the text appears white. I attempted to use the mix-blend-mode
property, but it does not seem to be working as expected. Why is this happening?
Here is a quick demonstration:
h1 {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: black;
font-size: 9rem;
mix-blend-mode: difference;
z-index: 1;
}
.centered-block {
position: absolute;
top: 50%;
left: 50%;
transform: translateY(calc(-50% - 10vh)) translateX(-50%);
width: 22.5rem;
height: 30rem;
background-color: black;
}
<h1>This<br/>is a<br/>test</h1>
<div class="centered-block"/>