Moon animation

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

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

<head>
  <meta charset="UTF-8">
  <title>Moon animation</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <body>
  <div class="moon"></div>
</body>
  
  

</body>

</html>

/*Downloaded from https://www.codeseek.co/VBagmut/moon-animation-dVzxeG */
body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;  /* fallback for old browsers */
background: -webkit-linear-gradient(to top, #434343, #000000);  /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to top, #434343, #000000); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
  margin: 0;
  
}

.moon {
    width: 292px;
    height: 277px;
    background-image: url("https://i.imgur.com/6sxAsWB.png");
    
    -webkit-animation: moon-animation 1s steps(13) infinite;
       -moz-animation: moon-animation 1s steps(13) infinite;
        -ms-animation: moon-animation 1s steps(13) infinite;
         -o-animation: moon-animation 1s steps(13) infinite;
            animation: moon-animation 1s steps(13) infinite;
}

@-webkit-keyframes moon-animation {
   from { background-position:    0px; }
     to { background-position: 3800px; }
}

@-moz-keyframes moon-animation {
   from { background-position:    0px; }
     to { background-position: 3800px; }
}

@-ms-keyframes moon-animation {
   from { background-position:    0px; }
     to { background-position: 3800px; }
}

@-o-keyframes moon-animation {
   from { background-position:    0px; }
     to { background-position: 3800px; }
}

@keyframes moon-animation {
   from { background-position:    0px; }
     to { background-position: 3800px; }
}

Comments