I'm struggling to have text vertically centred within a background image which has a scroll effect.
I have Top: 34%; at the moment to centre the text on my screen however, that is 34% from the top of the navigation menu. Is there a way for me to set it to 50% from the image that is showing? I'm fine with centring text on a normal image with no scroll effect, however, I feel having background-image (css) with scroll effect rather than a normal img tag on the html page is effecting the result.
This is how I would like it to look like but done with proper margins that make it stay centred. Left: 50%; Top: 34%; That is the margins set in the following image:
.home-section-image {
/* The image used */
background-image: linear-gradient(
rgba(8, 8, 8, 0.05),
rgba(8, 8, 8, 0.25)
),url("../images/pexels-photo-258109.jpg");
opacity: .80;
border-top: 1px solid #000;
/* Set a specific height */
min-height: 505px;
max-height: 505px;
margin: auto;
/* Create the image scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.home-section-image h2 {
position: absolute;
top: 34%;
left: 50%;
transform: translate(-50%, -50%);
color: #fff;
-webkit-text-stroke: black 2px;
text-align: center;
font-size: 5vw;
} /* Edits text overlaying image positioning, colour of text and adds stroke */
<section id="home" class="home-section">
<div class="home-section-image">
<h2>Kay Park Memorials</h2>
</div>
</section>