mit display: grid
CSS
#grid-section {
display: grid;
justify-content: center;
align-content: center;
}mit display: flexbox
CSS
.flexbox-section {
display: flex;
justify-content: center;
align-items: center;
}mit position: absolute
CSS
.hauptelement {
position: relative;
height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.hauptelement::before {
content: "";
position: absolute;
background: url('path_to_your_image.jpg') no-repeat center center;
background-size: cover;
width: 50px;
height: 50px;
left: 50%;
top: 50%;
transform: translate(-50%, -50%); // use the important values in here
}