Eclipse

In this example below you will see how to do a Eclipse with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by jonasroessum, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright jonasroessum ©
  • HTML
  • CSS
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Eclipse</title>
  
  
  
      <style>
      /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */
      body {
  background-color: #000;
  overflow: hidden;
}

.eclipse {
  height: 20em;
  width: 20em;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  position: absolute;
}

.moon, .shadow {
  height: 100%;
  width: 100%;
  border-radius: 50%;
}

.moon {
  position: relative;
  background-color: #d6c25c;
  box-shadow: 0 0 25em 3em #e0d185;
  overflow: hidden;
  animation: darken 30s cubic-bezier(0, 1, 1, 0) infinite;
}

.shadow {
  position: relative;
  top: -20em;
  right: 300%;
  background-color: black;
  box-shadow: 0 0 1em 1em black;
  animation: shadowMove 30s cubic-bezier(0, 1, 1, 0) infinite;
  transition: right 1s;
}

@keyframes darken {
  0% {
    box-shadow: 0 0 25em 3em #e0d185;
  }
  49% {
    box-shadow: 0 0 1em 2em #e0d185;
  }
  50% {
    box-shadow: 0 0 1em 2em #e0d185;
  }
  51% {
    box-shadow: 0 0 1em 2em #e0d185;
  }
  100% {
    box-shadow: 0 0 25em 3em #e0d185;
  }
}
@keyframes shadowMove {
  0% {
    right: -300%;
  }
  /*   45% {
      right: 0;
    }
    55% {
      right: 0;
    }
    */
  99.99999% {
    right: 300%;
  }
  100% {
    right: -300%;
  }
}

    </style>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>

</head>

<body>

  <div class="eclipse">
  <div class="moon">
  </div>
  <div class="shadow"></div>
</div>
  
  

</body>

</html>

/*Downloaded from https://www.codeseek.co/jonasroessum/eclipse-azZdMO */
body {
  background-color: #000;
  overflow: hidden;
}

.eclipse {
  height: 20em;
  width: 20em;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  position: absolute;
}

.moon, .shadow {
  height: 100%;
  width: 100%;
  border-radius: 50%;
}

.moon {
  position: relative;
  background-color: #d6c25c;
  box-shadow: 0 0 25em 3em #e0d185;
  overflow: hidden;
  animation: darken 30s cubic-bezier(0, 1, 1, 0) infinite;
}

.shadow {
  position: relative;
  top: -20em;
  right: 300%;
  background-color: black;
  box-shadow: 0 0 1em 1em black;
  animation: shadowMove 30s cubic-bezier(0, 1, 1, 0) infinite;
  transition: right 1s;
}

@keyframes darken {
  0% {
    box-shadow: 0 0 25em 3em #e0d185;
  }
  49% {
    box-shadow: 0 0 1em 2em #e0d185;
  }
  50% {
    box-shadow: 0 0 1em 2em #e0d185;
  }
  51% {
    box-shadow: 0 0 1em 2em #e0d185;
  }
  100% {
    box-shadow: 0 0 25em 3em #e0d185;
  }
}
@keyframes shadowMove {
  0% {
    right: -300%;
  }
  /*   45% {
      right: 0;
    }
    55% {
      right: 0;
    }
    */
  99.99999% {
    right: 300%;
  }
  100% {
    right: -300%;
  }
}

Comments