I want to make the ::after
pseudo element act as a shadow that stays in place, but the button has a translate on :hover
.
button {
border: solid 1px black;
border-radius: 4px;
padding: 0.8rem 1rem;
cursor: pointer;
position: relative;
&::after {
content: '';
width: 100%;
height: 100%;
position: absolute;
background: black;
left: 2px;
top: 2px;
z-index: -1;
border-radius: inherit;
}
&:hover {
transform: translate(-4px, -4px);
&::after {
transform: translate(4px, 4px);
}
}
}
Everything's fine until I hover.
Also, why is just the background covered by the pseudo element, leaving the button text on top? How do I get around this?