<div class="starfield">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
</div>
@keyframes starfieldRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

body, html {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

.starfield {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position:relative
}

.starfield > * {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;

  background-size: 200px 200px;
  background-image: radial-gradient(
      3px 3px at 40px 60px,
      #ccc,
      rgba(0, 0, 0, 0)
    ),
    radial-gradient(2px 2px at 20px 50px, #ddd, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 30px 100px, #eee, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 40px 60px, #fff, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 110px 90px, #ccc, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 190px 150px, #ddd, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 90px 123px, #ddd, rgba(0, 0, 0, 0)),
    radial-gradient(2px 2px at 25px 200px, #ddd, rgba(0, 0, 0, 0));
  background-repeat: repeat;
  transform-origin: 50% 50%;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
  animation-name: starfieldRotate
}

.starfield > *:nth-child(1) {
  animation-duration: 10s;
}

.starfield > *:nth-child(2) {
  animation-duration: 12s;
}

.starfield > *:nth-child(3) {
  animation-duration: 15s;
}

.starfield > *:nth-child(4) {
  animation-duration: 21s;
}

.starfield > *:nth-child(5) {
  animation-duration: 24s;
}

.starfield > *:nth-child(6) {
  animation-duration: 29s;
}

.starfield > *:nth-child(7) {
  animation-duration: 32s;
}

.starfield > *:nth-child(8) {
  animation-duration: 36s;
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.