0

I am trying to position a triangle underneath a tooltip. However the stacking order can not be changed using z-index. It seems this has no effect.

I have applied a position to both elements but nothing has an effect. Is there a way to position the triangle underneath the tooltip?

You can find a pen here: https://codepen.io/dwigt/pen/XWedvZv

<div class="triangle">This is a CSS3 triangle with a proper box-shadow!</div>


body {
  background-color: #888;
}

.triangle {
  position: relative;
  margin: 3em;
  padding: 1em;
  box-sizing: border-box;
  background: #bada55;
  box-shadow: 0px 3px 3px 0 rgba(0, 0, 0, 0.4);
}
.triangle::after{
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    margin-left: -0.5em;
    bottom: -2em;
    left: 50%;
    box-sizing: border-box;
    
    border: 1em solid black;
    border-color: transparent transparent #bada55 #bada55;
    
    transform-origin: 0 0;
    transform: rotate(-45deg);
    
    box-shadow: -3px 3px 3px 0 rgba(0, 0, 0, 0.4);
  }

.triangle--problem {
  position: relative;
  margin: 5em;
  padding: 1em;
  box-sizing: border-box;
  
  background: #bada55;
  
  box-shadow: 0px 3px 3px 0 rgba(0, 0, 0, 0.4);
  
}
.triangle--problem::after {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    margin-left: -0.75em;
    bottom: -3em;
    left: 50%;
    box-sizing: border-box;
    
    border: 1.5em solid black;
    border-color: #bada55 transparent transparent transparent;
    
    box-shadow: 0px 3px 3px 0 rgba(0, 0, 0, 0.4);
  }
dwigt
  • 611
  • 1
  • 8
  • 18

0 Answers0