Как родительским элементом перекрыть псевдоэлемент дочернего?

Хочу чтобы parent перекрывал child

<div class="parent">
  <div class="child"></div>
</div>


.parent {
  width: 100px;
  height: 100px;
  background: green;
  position: relative;
  z-index: 100;
}

.child {
  position: relative;
  z-index: 90;
}

.child:before {
  content: "";
  position: absolute;
  background: red;
  width: 50px;
  height: 50px;
  top: 60px;
  left: 60px;
  z-index: 10;
}


https://jsfiddle.net/L4t6gsdf/1/
  • Вопрос задан
  • 117 просмотров
Решения вопроса 1
wapster92
@wapster92 Куратор тега CSS
Пригласить эксперта
Ответы на вопрос 1
@drawnofmymind
.parent {
    width: 100px;
    height: 100px;
    background: green;
    position: relative;
    overflow: hidden;
}

.child {
    position: relative;
    z-index: -1;
}
.child:before {
    content: "";
    position: absolute;
    background: red;
    width: 50px;
    height: 50px;
    top: 60px;
    left: 60px;
    z-index: 10;
}


так?
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы