I am trying to create two-colored border with pseudo-element. But if I add z-index to the parent ".d" it stops working. Is there a way to have "position: relative" and "z-index" on ".d" and make this work?
.d {
  background-color: #000;
  height: 100px;
  width: 100px;
  /*z-index: 1000;  */
  /* Stops working if I add z-index */
  position: relative;
}
.d:before {
  content: "";
  border: #0000ff 4px dashed;
  background-color: #ff0000;
  top: -2px;
  left: -2px;
  bottom: -2px;
  right: -2px;
  position: absolute;
  z-index: -1;
}<div class="d"></div> 
    