I have h1 that has position "absolute" inside div that has position "relative" but when I set my h1 top:50% left:50% it stands in the middle of viewport and not in the middle of parent div. so nearest parent is ignored for some reason.
HTML:
<div class="container">
<div class="mshobeli">
<div class="shvili black"></div>
<div class="shvili red"></div>
<div class="shvili green"></div>
</div>
<div class="pinkfloyd">
<img src="https://c4.wallpaperflare.com/wallpaper/785/284/983/music-pink-floyd-wallpaper-preview.jpg"
alt="pink floyd logo">
<h2>Pink Floyd</h2>
</div>
Here is css
.pinkfloyd {
display: inline-block;
position: relative;
}
h2 {
font-size: 30px;
color: orangered;
position: absolute;
top: 50%;
left: 50%;
}