I tried creating a hero image with text, but the background is visible behind the text. My text is white and the site is black
#hero-header{
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("friends-cover2.jpg");
background-position: center;
background-size: cover;
background-repeat: no-repeat;
height:66vh;
margin-top: 25vh;
position: relative;
grid-area: hea;
}
.hero-header-text {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
background-color: transparent;
}
<header id="hero-header">
<div class='hero-header-text'>
<h1>WELCOME</h1>
<h3>welcome to the ultimatime FRIENDS fan page, where you will find an episode guide and trivia about the show.</h3>
<button>Read more.</button>
</div>
</header>
I have tried several things but can somehow not make it work.
2
Answers
To hide the background image behind the text, add a
background-color
property to the.hero-header-text
class and set it to a solid color, such as white. Here’s the updated CSS:Ensure that the button element is also positioned correctly and has a background color that blends with the text background. Here’s an updated code snippet for the button:
Make sure that the
hero-button
class is applied to the button element in your HTML code.I hope this helps!
Assalam Alaikum 🙂
Menimcha bu siz so’ragan narsa bo’lsa kerak