Sto creando un sito Web di sistema solare in puro codice senza immagini utilizzate. Il problema è che non riesco a capire come ottenere stelle sullo sfondo. Sto cercando di ottenere qualcosa come un motivo a pois giallo su sfondo nero. Questo è il mio codice (ripetere div e styling per ogni altro pianeta).Creazione di uno sfondo stellato nei CSS
html,
body {
width: 100%;
height: 100%;
background-color: black;
}
#sun {
position: absolute;
top: 50%;
left: 50%;
height: 200px;
width: 200px;
margin-top: -100px;
margin-left: -100px;
border-color: orange;
border-width: 2px;
border-style: solid;
border-radius: 50%;
box-shadow: 0 0 64px yellow;
background-color: yellow;
}
#mercury {
position: absolute;
top: 0;
left: 50%;
height: 10px;
width: 10px;
margin-left: -5px;
margin-top: -5px;
border-radius: 50%;
background-color: #ffd9b3;
}
#mercury-orbit {
position: absolute;
top: 50%;
left: 50%;
width: 260px;
height: 260px;
margin-top: -130px;
margin-left: -130px;
border-width: 2px;
border-style: dotted;
border-color: white;
border-radius: 50%;
-webkit-animation: spin-right 22s linear infinite;
-moz-animation: spin-right 22s linear infinite;
-ms-animation: spin-right 22s linear infinite;
-o-animation: spin-right 22s linear infinite;
animation: spin-right 22s linear infinite;
}
@-webkit-keyframes spin-right {
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes spin-right {
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
<div id="sun"></div>
<div id="mercury-orbit">
<div id="mercury"></div>
</div>
Hi try ispirano qui: http://codepen.io/search/pens/?limit=all&page= 9 & q = stars – Booster
mi piacerebbe sapere come rendere le tue orbite ellittiche .... – holden
Vuoi farlo in puro CSS? Un'alternativa (diversa da javascript) potrebbe essere quella di usare una piccola immagine di sfondo e ripeterla con 'background-repeat: repeat-x' e' background-repeat: repeat-y' – McVenco