4
This effect is known as Knockout Text. I made this template to help you as an example. It works well on Chrome and FF, but on IE gets a little buggy for a change...
Follow the CSS / HTML
div {
width: 300px;
height: 300px;
position: relative;
display: flex;
background-image: url(http://placecage.com/300/300);
background-position: center;
background-repeat: no-repeat;
margin: 10px auto;
}
div::after {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: #000;
width: 90%;
height: 100px;
margin: auto;
}
h1 {
text-align: center;
color: #fff;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-image: url(http://placecage.com/300/300);
background-position: center;
background-repeat: no-repeat;
margin: auto;
font-size: 42px;
font-family: sans-serif;
font-weight: bold;
padding: 0;
z-index: 1;
}
h1::after {
content: attr(data-title);
-webkit-background-clip: initial;
-webkit-text-fill-color: initial;
background-image: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, 80%);
}
<div>
<h1 data-title="Knockout">Knockout</h1>
</div>
The articles I used as a reference are: https://css-tricks.com/how-to-do-knockout-text/ and http://nimbupani.com/using-background-clip-for-text-with-css-fallback.html
Unfortunately, because of the hierarchy, you will not succeed unless you separate the elements and position later. Then you can give that expected effect.
– DiegoSantos
In order not to waste time, I played a picture in . png. Thanks in the same way!
– Caio Oliveira
Face, it is easier to use the rgba, the "a" would be the opacity, only of the background. Uses thus: background-color: rgba(255,255,255,0.5);
– Juan Takara