Is there a way to keep text centered over an image when resizing the browser window to ensure responsiveness? I've tried positioning the text as an absolute element, but it keeps overflowing the boundaries of the image. How can I prevent this?
.banner {
display: block;
width: 100%;
}
.banner-img {
display: block;
width: 100%;
}
.banner-text {
position: absolute;
top: 30%;
left: 25%;
font-size: 70px;
color: aliceblue;
font-family: 'Merriweather', serif;
text-align: center;
width: auto;
}
<div class="banner">
<img class="banner-img" alt="banner image" src="images/banner.jpg">
<div class="banner-text">Hello, Welcome To My Portfolio!
<p>I'm Nicholas!</p>
</div>
</div>