Below is my simple HTML and CSS code:
HTML:
<div class="header">
<div class="tip"></div>
</div>
CSS:
.header {
display: block;
width: 260px;
min-height: 222px;
background-color: #252525;
position: relative;
z-index: 5;
-webkit-box-shadow: 0 0 5px #000;
-moz-box-shadow: 0 0 5px #000;
box-shadow: 0 0 5px #000;
border-radius: 2px;
}
.tip {
display: inline-block;
width: 10px;
height: 10px;
right: 11px;
top: -5px;
transform: rotateZ(45deg);
position: absolute;
z-index: 1;
background-color: red;
-webkit-box-shadow: 0 0 5px #000;
-moz-box-shadow: 0 0 5px #000;
box-shadow: 0 0 5px #000;
}
I am trying to position the .tip
block under the .header
block.
However, despite setting the z-index of .tip
lower than that of .header
, it still appears on top:
https://i.sstatic.net/WJE2b.png
This is the desired outcome: https://i.sstatic.net/SEjWH.png
The issue lies with the z-index not functioning as expected.
I need to specify the z-index for the .header
block due to other blocks on the page also having z-index values.