I have two spinners, one with borders and a keyframes animation, the other one blank. If I target both spinners with jQuery, only the blank spinner is working.
I thought that maybe the ::before pseudo element was blocking the "click" when you hover over the element, but as you can see here, that's also on the second spinner.
What (else) can be the problem?
$(".spinner").click(function() {
$(this).toggleClass("scale");
});
*,
*::before,
*::after {
box-sizing: border-box;
}
body,
html {
height: 100%;
margin: 0;
}
body {
background: #ccc;
}
.spinner {
width: 100px;
height: 100px;
background: #E2E2E2;
border-radius: 50%;
position: relative;
margin: 50px;
display: inline-block;
transition: transform .2s ease-in-out;
}
.spinner:after,
.spinner:before {
content: "";
display: block;
width: 100px;
height: 100px;
border-radius: 50%;
}
.spinner-1 {
border-left: 2px solid red;
border-right: 2px solid blue;
border-top: none;
border-bottom: none;
animation: spin-1 1s ease-in-out infinite;
}
@keyframes spin-1 {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.scale {
transform: scale(1.1);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="spinner spinner-1"></div>
<div class="spinner spinner-2"></div>