I am working on a category section where the image has has a category on the top right, titles on the bottom left and a linear gradient at the bottom i.e., the background of the titles. Using a pseudo class :after I want to insert the linear gradient to the background. As you can see the image is in the HTML tag not in the background but it won't work even when I give z-index. What am I doing wrong?
Any Suggestions and help are appreciated.
Thanks in advance.
a {
text-decoration: none;
}
.category-list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
list-style-type: none;
}
.category-list li {
flex: 0 1 31%;
position: relative;
}
.category-details img:after {
display: block;
position: absolute;
width: 100%;
height: 103px;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4), rgb(0, 0, 0, 0.7));
z-index: 999;
}
.category {
position: absolute;
top: 10%;
right: 10%;
background-color: #00ae6f;
color: #ffffff;
padding: 0px 10px;
}
.category-details {
position: relative;
}
.overlay-title {
position: absolute;
bottom: 10%;
left: 10%;
color: #fff;
}
.overlay-title h3 {
font-size: 20px;
font-weight: 700;
}
.overlay-title h5 {
font-size: 14px;
font-weight: 200;
}
<ul class="category-list">
<li>
<div class="category-details">
<img class="category-img" src="https://image.ibb.co/dWGHdG/kimberlyphoto_medium.jpg" />
<a href="#" class="category">Education</a>
<div class="overlay-title">
<h3>Elementary school</h3>
<h5>297 stephens st. pressville</h5>
</div>
</div>
</li>
<li>
<div class="category-details">
<img class="category-img" src="https://preview.ibb.co/eEi2Cb/CBSE_Building_design_plans.jpg" />
<a href="#" class="category">Education</a>
<div class="overlay-title">
<h3>Elementary school</h3>
<h5>297 stephens st. pressville</h5>
</div>
</div>
</li>
<li>
<div class="category-details">
<img class="category-img" src="https://image.ibb.co/dWGHdG/kimberlyphoto_medium.jpg" />
<a href="#" class="category">Education</a>
<div class="overlay-title">
<h3>Elementary school</h3>
<h5>297 stephens st. pressville</h5>
</div>
</div>
</li>
</ul>