cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="universe-wrapper">
  <div class="stars-wrapper"></div>
  <div class="asteroid">
    <div class="extras"></div>
  </div>
  <div class="planets-wrapper">
    <div class="moon"></div>
    <div class="earth">
      <div class="eye left"></div>
      <div class="eye right"></div>
      <div class="mouth"></div>
    </div>
  </div>
</div>
            
          
!
            
              @mixin transform($info) {
  transform: $info;
  -webkit-transform: $info;
  -moz-transform: $info;
  -ms-transform: $info;
}
@mixin gradient($type, $info) {
  background: #{$type}-gradient($info);
  background: -webkit-#{$type}-gradient($info);
  background: -moz-#{$type}-gradient($info);
  background: -ms-#{$type}-gradient($info);
}
@mixin browsers($info) {
  animation: $info;
  -webkit-animation: $info;
  -moz-animation: $info;
  -ms-animation: $info;
  -o-animation: $info;
}
@mixin blur($info) {
  filter: blur($info);
  -webkit-filter: blur($info);
  -moz-filter: blur($info);
  -ms-filter: blur($info);
  -o-filter: blur($info);
}
@mixin animation($name) {
  @keyframes #{$name} {
    @content;
  }
  @-webkit-keyframes #{$name} {
    @content;
  }
  @-moz-keyframes #{$name} {
    @content;
  }
  @-ms-keyframes #{$name} {
    @content;
  }
}

/* colors */
$sky: #363640;

$black: #222;
$white: #eee;

$earth-sea: #496282;
$earth-green: #5E8249;

$moon: #E0E0DE;

$asteroid: #6E2E2E;
$asteroid-2: #B36A36;

$time: 3s;

body {
  background-color: $sky;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  width: 100vw;
}

.planets-wrapper {
  align-items: center;
  display: flex;
  height: 100vh;
  justify-content: center;
  width: 100vw;
}

.earth {
  background-color: $earth-sea;
  border-radius: 100%;
  box-shadow: inset -3px -3px $earth-sea - 15;
  height: 50px;
  position: relative;
  width: 50px;
  z-index: 2;
  @include browsers(earthJump 3.76s -1.4s linear infinite);
  &:before {
    background-color: $earth-green;
    border-radius: 100% 70% 100% 70%;
    content: '';
    height: 32px;
    left: 3px;
    position: absolute;
    top: 15px;
    width: 15px;
    @include transform(rotate(-30deg));
  }
  &:after {
    @extend .earth:before;
    height: 12px;
    left: 27px;
    top: 3px;
    width: 10px;
    @include transform(rotate(-45deg));
  }
  .eye {
    background-color: $black;
    border-radius: 100%;
    height: 7px;
    position: absolute;
    top: 17px;
    width: 7px;
    &:after {
      background-color: $white;
      border-radius: 100%;
      content: '';
      height: 2px;
      position: absolute;
      width: 2px;
      @include browsers(earthEye $time linear infinite);  
    }
    &.left {
      left: 14px;
    }
    &.right {
      right: 14px;
    }
  }
  .mouth {
    border-bottom: 2px solid $black;
    border-radius: 100%;
    bottom: 15px;
    left: 0;
    margin: auto;
    position: absolute;
    right: 0;
    width: 17px;
    @include browsers(earthMouth $time linear infinite);
  }
}

.moon {
  background-color: $moon;
  border-radius: 100%;
  box-shadow: inset -3px -3px $moon - 15;
  height: 20px;
  left: 110px;
  position: relative;
  top: 20px;
  width: 20px;
  @include browsers(moonJump 4.45s -0.22s linear infinite);
  &:after {
    background-color: $moon - 35;
    border-radius: 100%;
    content: '';
    height: 5px;
    left: 9px;
    position: absolute;
    top: 4px;
    width: 5px;
  }
  &:before {
    @extend .moon:after;
    height: 3px;
    left: 4px;
    top: 13px;
    width: 3px;
  }
}

.asteroid {
  background-color: $asteroid - 15;
  border-radius: 100%;
  height: 20px;
  position: absolute;
  width: 20px;
  z-index: 1;
  @include transform(rotate(25deg));
  @include browsers(asteroidHit $time linear infinite);
  .extras { display: none;
    background-color: $asteroid + 25;
    height: 1px;
    opacity: 1;
    position: absolute;
    right: -150px;
    width: 30px;
    @include transform(rotate(5deg));
    @include blur(1px);
    &:after {
      background-color: $asteroid + 25;
      content: '';
      height: 1px;
      position: absolute;
      right: 0;
      top: 20px;
      width: 30px;
      @include transform(rotate(-5deg));
    }
    &:before {
      background-color: $asteroid + 25;
      content: '';
      height: 1px;
      position: absolute;
      right: -25px;
      top: 8px;
      width: 15px;   
    }
  }
  &:after {
    background-color: $asteroid + 25;
    border-radius: 100% 0 0 100%;
    content:  '';
    height: 32px;
    left: -6px;
    opacity: 0.7;
    position: absolute;
    top: -6px;
    width: 32px;
    @include blur(1px);
  }
  &:before {
    border-bottom: 16px solid transparent;
    border-left: 150px solid $asteroid + 25;
    border-top: 16px solid transparent;
    content: '';
    left: 24.5px;
    opacity: 0.7;
    position: absolute;
    top: -6px;
    width: 10px;
    @include blur(1px);
  }
}

/* animations */
@include animation(earthJump) {
  0% {
    top: 0px;
  }
  30% {
    top: -5px;
  }
  70% {
    top: 5px;
  }
  100% {
    top: 0px;
  }
}
@include animation(moonJump) {
  0% {
    top: -25px;
  }
  30% {
    top: -30px;
  }
  70% {
    top: -20px;
  }
  100% {
    top: -25px;
  }
}
@include animation(asteroidHit) {
 from {
    top: 100vh;
    left: 100vw;
  }
  to {
    top: 15vh;
    left: -100px;
  }
}
@include animation(earthMouth) {
  0% {
    height: 10px;
  }  
  40% {
    height: 10px;
  }
  45% {
    height: 0px;
  }
  55% {
    height: 0px;
  }
  60% {
    height: 10px;
  }
  100% {
    height: 10px;
  }
}
@include animation(earthEye) {
  0% {
    left: 2px;
    top: 1px;
  }  
  40% {
    left: 2px;
    top: 1px;
  }
  45% {
    left: 1px;
    top: 4px;
  }
  55% {
    left: 1px;
    top: 4px;
  }
  60% {
    left: 2px;
    top: 1px;
  }
  100% {
    left: 2px;
    top: 1px;
  }
}

/* sky/universe background */
.stars{
  background-color: #f9f9f9;
  border-radius: 5px;
  display: inline-block;
  position: absolute;
}

@for $i from 1 through 75{
  .s#{$i}{
    $speed: random(15) + 10 + s;
    $delay: - (random(25)) + s;
    $size: random(1) + 0.5px;
    height: $size;
    left: random(100) + 0%;
    top: random(100) + 0%;
    width: $size;
    @include browsers(shiningStar $speed $delay infinite);
  }
}

/* animations */
@include animation(shiningStar) {
  0% { 
    opacity: 1; 
  }
  20% { 
    opacity: 0.5; 
  }
  40% {
    opacity: 0;
  }
  60% { 
    opacity: 0.5; 
  }
  80% {
    opacity: 0.75;
  }
  100% {
    opacity: 1;
  }
}
            
          
!
            
              $(function(){
  /* creating stars */
  for (i = 0; i < 75; i++)
    $(".stars-wrapper").append("<div class='stars s" + i +"'></div>");  
  
});
            
          
!
999px
Loading ..................

Console