<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content=
"width=device-width, initial-scale=1.0">
<title>
How to place the background image
using ::before pseudo selectors ?
</title>
<style>
* {
margin: 0px;
padding: 0px;
}
body {
text-align: center;
}
h1 {
color: green;
}
.container {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
color: black;
font-weight: bold;
font-size: 2rem;
}
.container::before {
content: '';
background: url('bg.png')
no-repeat center center/cover;
position: absolute;
opacity: 0.3;
top: 0px;
left: 0px;
width: 100vw;
height: 100vh;
z-index: -1;
}
span {
font-size: 2em;
}
</style>
</head>
<body>
<div class="container">
GeeksforGeeks<br><br>
How to place background image using
::before pseudo selectors ?
</div>
</body>
</html>