As mentioned in the comments, one way to achieve this effect is by using the background-size
property.
To illustrate, I have put together a simple sample for you...
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
width: 100%;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-image: url('https://images.pexels.com/photos/1054218/pexels-photo-1054218.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1');
background-size: cover;
}
h1 {
font-family: sans-serif;
color: white;
}
<body>
<h1> Just a title</h1>
</body>
For more details on the background-size property, visit this link.
The background-size
property determines how an element's background image is sized, whether it should be stretched, left at its natural size, or constrained within the available space.
In the provided example, I used background-size: cover
which scales the image proportionally to fit the container without distorting it.