Как сделать псевдоэлемент под родителем
псевдоэлемент не отображается под родителем.
https://jsfiddle.net/nyawxtq2/5/ вот пример на фидл
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<button class="hero__btn btn">
test
</button>
</body>
</html>
body {
background-color: black;
}
.btn {
font-family: Raleway, sans-serif;
padding: 12px 30px;
font-size: 18px;
line-height: 142.4%;
color: #ffffff;
background-color: #AE0034;
border: none;
cursor: pointer;
position: relative;
z-index: 5;
}
.btn::after {
content: '';
width: 100%;
height: 100%;
background-color: transparent;
border: 1px solid #ffffff;
position: absolute;
top: 0;
left: 0;
z-index: 1;
transform: rotate(6.44deg);
}
Ответы (1 шт):
Автор решения: humster_spb
→ Ссылка
У родителя нужно убрать z-index совсем, а псевдоэлементу задать отрицательное значение:
body {
background-color: black;
}
.btn {
font-family: Raleway, sans-serif;
padding: 12px 30px;
font-size: 18px;
line-height: 142.4%;
color: #ffffff;
background-color: #AE0034;
border: none;
cursor: pointer;
position: relative;
}
.btn::after {
content: '';
width: 100%;
height: 100%;
background-color: transparent;
border: 1px solid #ffffff;
position: absolute;
top: 0;
left: 0;
z-index: -1;
transform: rotate(6.44deg);
}
<button class="hero__btn btn">
test</button>