In my website, I need to display a button where the background is white, and the text gets the color of the background below, which can be a solid color or a background image.
Since the background and the button location are dynamic, I can't use the solutions that where written here.
See Example below.
I'm looking for a css only solution.
Thanks for helping.


You can get this effect by adding the button's background in front of the text, using a pseudo element, and then using mix-blend-mode on the button (screen), and the pseudo element (color-burn) to create the cutout effect.
Note: this will only work if the button's background is white.
Note: mix-blend-mode is not supported by IE.
.button {
position: relative;
padding: 0.5em 1em;
font-size: 1.2em;
border: none;
background: none;
outline: none;
color: black;
mix-blend-mode: screen;
}
.button::before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: white;
border-radius: 0.3em;
content: '';
mix-blend-mode: color-burn;
}
.bg {
padding: 2em;
}
.bg1 {
background: purple;
}
.bg2 {
background: linear-gradient(to bottom, gold 50%, silver 50%);
}
<div class="bg bg1">
<button class="button">Text</button>
</div>
<div class="bg bg2">
<button class="button">Text</button>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With