Mein zweiter Ansatz:
- Die Werte werden automatisch mit Javascript berechnet und das CSS und das HTML generiert
Templates und CSS:
Code
<template id="anitpl">
.imgwrapper.nr{{nr}} {
animation: ani{{nr}} 2s infinite linear;
}
@keyframes ani{{nr}} {
from {
transform: rotate({{start}}deg);
}
to {
transform: rotate({{end}}deg);
}
}
</template>
<template id="rottpl">
<div class="imgwrapper nr{{nr}}">
<img src="images/moon-transparent.png">
</div>
</template>
<style id="dynstyle"></style>
<style>
#rotwrapper {
display: flex;
align-items: center;
justify-content: center;
background-color: lightblue;
width: 600px;
height: 600px;
position: relative;
}
#rotwrapper img#centerimg {
width: 300px;
height: 300px;
}
#rotwrapper .imgwrapper img {
width: 74px;
height: 74px;
position: absolute;
top: 0;
left: 263px;
}
.imgwrapper {
position: absolute;
top: 0;
left: 0;
width: 600px;
height: 600px;
transform-origin: center center;
}
</style>
Alles anzeigen
HTML und Javascript:
Code
<div id="rotwrapper">
<img id="centerimg" src="images/earth-transparent.png">
</div>
<script>
var vdynstyle = document.getElementById("dynstyle");
var vanitpl = document.getElementById("anitpl");
var vrottpl = document.getElementById("rottpl");
var vrotwrapper = document.getElementById("rotwrapper");
var nrimg = 13;
for (var i = 0; i < nrimg; i++) {
var start = 360 / nrimg * i;
var end = 360 + start;
var ani = vanitpl.innerHTML.replace("{{start}}", start)
.replace("{{end}}", end)
.replace(/\{\{nr\}\}/g, i + 1);
vdynstyle.innerHTML += ani;
var rotimg = vrottpl.innerHTML.replace("{{nr}}", i + 1);
vrotwrapper.innerHTML += rotimg;
}
</script>
Alles anzeigen
Was noch fehlt: Unterschiedliche Bilder. Am besten die URLs in einem Array ablegen und in das Template einfügen.