<div class="container">
<div class="spinnerOuterBox">
<div class="spinner"></div>
</div>
</div>
.container { position: relative;
border: 1px dotted darkslategray;
}
.spinnerOuterBox { position: absolute;
width: 50px; height: 50px;
}
.spinner { position: absolute;
width: 50px; height: 50px;
background: url(images/smiley-50x50.png);
border-radius: 50%;
}
.move { left: 0;
animation: 5s move ease-in-out alternate infinite
}
@keyframes move {
to {left: 250px}
}
.scale { transform: scale(.1);
animation: 5s scale ease-in-out alternate infinite
}
@keyframes scale {
to {transform: scale(1)}
}
.spinning { transform: rotate(0deg);
animation: 1.5s spinning linear infinite
}
@keyframes spinning {
to {transform: rotate(360deg)}
}
Goal is to let the spinner spin, independent of the moving and scaling of the spinner.
Tested is on a Windows-7 Professional PC, 64bit, with Intel Core i5-2400 (4 cores) 3.10 GHz processor and 6GB RAM; Edge on Windows-10.
To be sure that nothing is staying in the cache (browser cache or memory cache), is between each test:
spinnerOuterBox: move
spinner........: spinning
Good ....:
Chrome, Opera, Firefox, IE-11, EdgespinnerOuterBox: scale
spinner........: spinning
Good ....:
Chrome, Opera, Firefox, IE-11, EdgespinnerOuterBox: move + scale
spinner........: not spinning
Good ....:
Chrome, Opera, Firefox, IE-11, EdgespinnerOuterBox: move + scale
spinner........: spinning
Good ....:
Firefox, IE-11, EdgeWrong ...:
Chrome, Opera (blurry, or blurry after refresh)
spinnerOuterBox: move + scale
spinner........: spinning with CSS delay (2.5s)
Good ....:
Firefox, IE-11, EdgeWrong ...:
Chrome, Opera (blurry, or blurry after refresh)
spinnerOuterBox: move + scale, with CSS delay (2.5s)
spinner........: spinning
Good ....:
Firefox, IE-11, EdgeWrong ...:
Chrome, Opera (blurry, or blurry after refresh)
.spinningBlinkHack {
animation:
.01s spinning linear forwards,
1.5s .02s spinning linear infinite;
}
spinnerOuterBox: move + scale
spinner........: spinning with CSS BlinkHack
Good ....:
Chrome, Opera, IE-11, EdgeWrong ...:
Firefox ! (not spinning, is giving the 'forwards' priority, although not the last task in the style rule)
<div class="spinner spinningBlinkHack"
id="jsDelay30ms"></div>
<script>
function spinnerJSdelay30ms() {
document.getElementById("jsDelay30ms").style.animation
= "1.5s spinning linear infinite";
}
setTimeout(spinnerJSdelay30ms, 30);
</script>
spinnerOuterBox: move + scale
spinner........: spinning with CSS Hack + JS (.03s)
Good ....:
Firefox, IE-11, EdgeWrong ...:
Chrome, Opera (blurry, or blurry after refresh)
<div class="spinner spinningBlinkHack"
id="jsDelay50ms"></div>
<script>
function spinnerJSdelay50ms() {
document.getElementById("jsDelay50ms").style.animation
= "1.5s spinning linear infinite";
}
setTimeout(spinnerJSdelay60ms, 50);
</script>
spinnerOuterBox: move + scale
spinner........: spinning with CSS Hack + JS (.05s)
Good ....:
Firefox, IE-11, EdgeWrong ...:
Chrome, Opera (blurry, or blurry after refresh)
<div class="spinner spinningBlinkHack"
id="jsDelay100ms"></div>
<script>
function spinnerJSdelay100ms() {
document.getElementById("jsDelay100ms").style.animation
= "1.5s spinning linear infinite";
}
setTimeout(spinnerJSdelay100ms, 100);
</script>
spinnerOuterBox: move + scale
spinner........: spinning with CSS Hack + JS (.1s)
Good ....:
Chrome, Opera, Firefox, IE-11, EdgeAttention!
While javascript is not reliable in timing (depends on possible other running scripts or processing tasks; for instance the Developer Tools), security margins
will be needed; and testing in reality!
<div class="spinner spinningBlinkHack"
id="jsDelay1000ms"></div>
<script>
function spinnerJSdelay1000ms() {
document.getElementById("jsDelay1000ms").style.animation
= "1.5s spinning ease-in 1,
1.5s 1.5s spinning linear infinite";
// slow start first turn, normal after first turn
}
setTimeout(spinnerJSdelay1000ms, 1000);
</script>
spinnerOuterBox: move + scale
spinner........: spinning with CSS Hack + JS (1s)
Good ....:
Chrome, Opera, Firefox, IE-11, EdgeWrong ...:
nobody (on my pc)
<div class="spinner" id="jsDelay1000msNohack"></div>
spinnerOuterBox: move + scale
spinner........: spinning + JS (1s)
Good ....:
Chrome, Opera, Firefox, IE-11, EdgeWrong ...:
nobody (on my pc)
< back to CSS spinner recommendations
Francky Kleyneman
original: 9 dec.2018
update: 12 jan.2019 (added: results Edge)