I'm trying to spin the a pseudo element, however, while the animation works perfectly on other elements, the pseudo element doesn't move.
HTML:
<div class="spinning">
some content
</div>
CSS:
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
.spinning::before {
content: 'x';
animation: spin 2s infinite linear;
}
jsfiddle: https://jsfiddle.net/7x0tasnh/
Applying the animation rule to the div
works, with ::before
it doesn't work. What am I missing?
Add display: inline-block
to your :before
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
.spinning::before {
content: 'x';
animation: spin 2s infinite linear;
display: inline-block;
}
<div class="spinning"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With