I am facing a challenge with displaying an image within a container. The container has a background image with the position set to relative and contains some text. I would like to display another image within this container, with the position set to absolute. However, I am encountering an issue where if the image has a positive z-index, it covers the text, and if it has a negative z-index, it goes under the container's background image, making it invisible.
As a beginner in HTML and CSS, I am seeking assistance from someone who is knowledgeable in this area. Please excuse any shortcomings in my English.
.banner {
background: url(../img/Banner-back.png) center center no-repeat;
background-size: cover;
text-align: center;
align-items: center;
justify-content: center;
font-family: Source Han Sans JP;
position: relative;
}
.banner-content {
z-index: 1
}
.creative {
position: absolute;
z-index: 0;
}
.text-shadow {
text-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}
.text-shadow01 {
text-shadow: -3px 0 white, 0 3px white, 3px 0 white, 0 -3px white, 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}
.text-shadow02 {
text-shadow: -3px 0 10px white, 0 3px 10px white, 3px 0 10px white, 0 -3px 10px white, 0 0 10px white;
}
.underline-text {
background: url(../img/underline.png) no-repeat;
background-size: 100% 20px;
background-position: bottom;
padding: 0.25rem;
}
.title01 {
font-size: 4.5rem;
}
.title02 {
font-size: 2.8rem;
}
.banner-content {
margin-left: 25vw;
text-align: left;
}
.creative {
width: 43%;
top: 6vw;
right: 40vw;
}
<div class="banner">
<div class="bg-green d-flex align-items-center justify-center">
<div class="banner-left"></div>
<div class="text-shadow text-white h1 p-3 mb-5">This is my header.</div>
<div class="banner-right"></div>
</div>
<div class="banner-content">
<div><img src="assets/img/Banner01.png"></div>
<div class="h1 mt-4">Promise</div>
<div class="title01 text-green text-shadow01">Hiquality</div>
<div class="title01 text-green text-shadow01">Sample text</div>
<div class="title02 text-shadow02">Sample text</div>
<div class="title02 text-shadow02" style="z-index: 1000">Sample text</div>
</div>
<div class="scroll-div">
<img class="scroll-bar" src="assets/img/Scroll-bar.png">
</div>
<div class="creative"><img src="assets/img/creative-team.png"></div>
</div>