I'm trying to add an orange accent to my banner text using the ::after
psuedo element.
goal:
I'm having two problems:
getting
:after
to show up when content is emptystacking the
:after
between the parent element and image. I've tried specifying z-indexes
(I forced the :after
to appear by putting dummy content so the stacking problem is shown)
html
<div className="hero-banner">
<div className="hero-banner-content">
<img src={img0} alt="image"/>
<div className="hero-banner-text">
<span className="highlighted">Master</span>
<span>the art of performance</span>
</div>
</div>
</div>
scss
.hero-banner {
position: relative;
top: 0;
left: 0;
height: 100vh;
.hero-banner-content {
position: relative;
top: -70px;
width: 100%;
img {
object-fit: cover;
width: 100%;
height: 100vh;
z-index: 1;
}
.hero-banner-text {
padding: 0 24px;
color: #FFFFFF;
font-size: 54px;
font-weight: $fw-bold;
width: 361px;
position: absolute;
top: 237px;
left: 192px;
.highlighted {
font-size: 96px;
display: block;
}
> * {
text-transform: uppercase;
z-index: 4;
}
&:after {
content: "_____";
height: 32px;
width: 200px;
background-color: $orange;
opacity: 0.4;
position: relative;
top: 32px;
left: -432px;
z-index: 2;
}
}
}
}