Although it may look complex, creating a window text effect is actually really easy to do using CSS and the mix-blend-mode property. The mix-blend-mode property determines the way in which an element’s content should blend with the element’s background.
In terms of your HTML, all you need to create the above effect is a div with some text inside it. For this example, we used a div with a class of “main” that contained an h1.
The main purpose of the div is to be a container for the background image. The styling of your div should look something like this:
- div.main{
- width: 700px;
- height: 500px;
- background: url('img/path');
- background-size: color;
- }
And your h1 should be styled similar to this:
- .main h1{
- font-size: 80px;
- text-align: center;
- top: 100px;
- padding: 15px;
- position: relative;
- font-family: sans-serif;
- color: #222;
- }
At this point, you should have something that looks like the image below.
We’re almost finished! We only need to add a few lines of CSS to achieve the window text effect. Adjust your h1 CSS so it looks like this:
- .main h1{
- font-size: 80px;
- text-align: center;
- top: 100px;
- padding: 15px;
- position: relative;
- font-family: sans-serif;
- color: #fff;
- background-color: #222;
- mix-blend-mode: multiply;
- }
All you need to do is change the text color to white, add a background color of your choice, and add the mix-blend-mode property with a value of multiply, and you should find yourself with something that looks a lot like the image below.