I've searched around for other answers but can't seem to fin one specifically... I'm using z-index correctly so I don't get why this is happening. That line you see in the example is supposed to go under the icon and over the sidebar but it is not.
I've tried so far
- Fiddling with the z-indexes
- Giving the icon in question position absolute
- placing the !important keyword on the z-index property
.
.container {
background-color: #d9d8d7;
width: 600px;
height: 500px;
display: grid;
grid-template-rows: repeat(6, 1fr);
grid-template-columns: repeat(6, 1fr);
grid-gap: 5px;
}
.text-container {
background: pink;
grid-column: 3 / -1;
grid-row: 1 / 3;
display: grid;
grid-template-rows: repeat(5, 1fr);
grid-template-columns: repeat(5, 1fr);
grid-gap: 5px;
}
.top-left-container {
grid-column: 1 / 4;
grid-row: 1 / 4;
position: relative;
background-color: orange;
/* position:relative; */
}
.horizontal-line {
position: absolute;
bottom: 75%;
left:-150%;
height: 2px;
width: 300%;
z-index: ;
background-color: black;
/* z-index level 2 "middle" */
z-index: 10;
}
.heading {
/* background-color:yellow; */
grid-column: 1 /-1;
grid-row: 1 / 2;
}
.sidebar {
background-color: lightblue;
grid-row: 1 / -1;
grid-column: 1 / 2;
display: flex;
flex-direction: column;
justify-content: start;
align-items: center;
/* z-index level 1 */
z-index: 5;
}
.sidebar__wrapper {
display: flex;
flex-direction: column;
/* background-color: red; */
}
.sidebar__icon {
margin: 10px;
height: 50px;
width: 50px;
z-index: 50;
/* z-index level 3 Why wont'this cover the div
that has a higher z-index than it */
z-index: 15;
}
<div class="container">
<div class="sidebar">
<div class="sidebar__wrapper">
<img src="https://cdn0.iconfinder.com/data/icons/images-icons-rounded/110/Image-Focus-512.png" alt="" class="sidebar__icon">
<img src="https://cdn0.iconfinder.com/data/icons/images-icons-rounded/110/Image-Focus-512.png" alt="" class="sidebar__icon">
<img src="https://cdn0.iconfinder.com/data/icons/images-icons-rounded/110/Image-Focus-512.png" alt="" class="sidebar__icon">
</div>
</div>
<div class="text-container">
<div class="top-left-container">
<div class="heading">Header Here</div>
<div class="horizontal-line"></div>
</div>
</div>
</div>