I would like to make the text white when it overlays some image, or to use image for changing some elements that interacts with it. In my example you can see the text is always black, but i wish to make it white (or other specific color) in part of overlaying image.
UPD: Only part that overlays image should change color. Other part must remain its original color. Also, image may be round or any random shape. Please, have a look at example EXAMPLE
body {
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
}
.container {
display: flex;
align-items: center;
}
.image {
background-image: url("https://upload.wikimedia.org/wikipedia/commons/f/ff/Solid_blue.svg");
width: 35vw;
height: 35vw;
}
.text {
position: relative;
font-size: 7vw;
right: 12vw;
}
<body>
<div class="container">
<div class="image"></div>
<span class="text">Some cool text</span>
</div>
</body>
I've tried to use mix-blend-mode, but I can't figure out how to make text exactly white or other specific color.
The
mix-blend-modeproperty allows you to blend the colors of the text and the background image in different ways in CSS. To make the text white, you can use the difference value formix-blend-modeand set the color of the text to white using thecolorproperty. Here's an example to see how it works:CSS Code:
This will make the text white when it overlays the blue image in your example. You can replace white with any other specific color you want.