Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .description
  %h1 Solar System
  %hr/
  %p
    I know this is not the first one on CodePen, but I'm a space and physics lover, and I wanted to create mine :)
  %p
    Here is a true time scaled solar-system, which means that every objects have a time relative to an Earth year.
    
    You can change the number in second of the
    %br/
    %code $seconds-per-year
    variable to modify the speed of revolutions. By default, 1 earth year will occur every 30 seconds.
  %p.hide
    Note the css tricks for the Saturn rings (box-shadow) and reverse animation to compensate the orbit.
  %hr/
  %p.author
    Made with
    %i.fa.fa-heart
    by Malik Dellidj
    %br/
    Refactored by TepigMC
  %p.links
    %a.fa.fa-codepen.icon{:href => "https://codepen.io/kowlor/", :target => "_blank"}
    
    %a.fa.fa-github-alt.icon{:href => "https://github.com/KOWLOR", :target => "_blank"}
    
    %a.fa.fa-twitter.icon{:href => "https://twitter.com/Dathink", :target => "_blank"}
    
    
.solar-syst
  .sun
  .mercury
  .venus
  .earth
  .mars
  .jupiter
  .saturn
  .uranus
  .neptune
  .pluto
  .asteroid-belt

            
          
!
            
              $seconds-per-year: 30; // 1 Earth year = 30 sec

@mixin size($v-size, $h-size: $v-size) {
  height: $v-size;
  width: $h-size;
  margin-top: -$v-size / 2;
  margin-left: -$h-size / 2;
}
@mixin revolution($revolution, $reverse: false) {
  animation: orbit revolution-speed($revolution) linear infinite;
  @if $reverse {
    animation-direction: reverse;
  }
}
@mixin planet($revolution, $orbit-size, $planet-size, $color, $reverse: false) {
  @extend %core;
  @extend %core-orbiting;
  @extend %core-sphere;
  @include size($orbit-size);
  @include revolution($revolution, $reverse);
  &:before {
    @include size($planet-size);
    background: $color;
  }
}
@mixin satellite() {
  position: absolute;
  content: "";
  left: 50%;
  top: 0px;
}

@function revolution-speed($planet-days-in-year) {
  @return $planet-days-in-year * $seconds-per-year / 365.2563 + s; // Earth reference
}
@function alphaRandom() {
  @return random(1000) * .001;
}
@function stars($amount, $max-area, $min-area: 0, $star-size: 0) {
  $stars: ''; 
  @for $i from 1 to $amount {
    $stars: '#{$stars}, #{$min-area + random($max-area)}px #{$min-area + random($max-area)}px 0 #{$star-size}px rgba(255, 255, 255, #{alphaRandom()})'
  }
  @return unquote($stars);
}

@keyframes orbit {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

*, *:before, *:after {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
}
body {
  font: normal 1em/1.45em "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: #fff;
  background: radial-gradient(ellipse at bottom, #1c2837 0%, #050608 100%);
  background-attachment: fixed;
}

.solar-syst {
  &:after {
    content: "";
    position: absolute;
    height: 2px;
    width: 2px;
    top: 50%;
    left: 50%;
    background: transparent;
    box-shadow: stars(500, 1800, -900);
    //border-radius: 100px;
  }
  margin: 0 auto;
  width: 100%;
  height: 100%;
  position: relative;
}

%core {
  border-radius: 1000px;
  top: 50%;
  left: 50%;
  position: absolute;
  z-index: 999;
}
%core-orbiting {
  border: 1px solid rgba(102, 166, 229, 0.12);
  &:before {
    left: 50%;
    border-radius: 100px;
    content: "";
    position: absolute;
  }
}
%core-sphere {
  &:before {
    box-shadow: inset 0 6px 0 -2px rgba(0, 0, 0, 0.25);
  }
}

.sun {
  @extend %core;
  @extend %core-sphere;
  @include size(40px);
  background: radial-gradient(ellipse at center, #ffd000 1%, #f9b700 39%, #f9b700 39%, #e06317 100%);
  background-clip: padding-box;
  border: 0 !important;
  background-position: -28px -103px;
  background-size: 175%;
  box-shadow: 0 0 10px 2px rgba(255, 107, 0, 0.4), 0 0 22px 11px rgba(255, 203, 0, 0.13);
}

.mercury {
  @include planet(87.969, 70px, 4px, #9f5e26);
}
.venus {
  @include planet(224.701, 100px, 8px, #beB768, true);
}
.earth {
  @include planet(365.2563, 145px, 6px, #11abe9);
  &:after {
    @include size(18px);
    @include revolution(27.3216);
    @include satellite();
    border-radius: 100px;
    box-shadow: 0 -10px 0 -8px grey;
  }
}
.mars {
  @include planet(686.980, 190px, 6px, #cf3921);
}
.asteroid-belt {
  @extend %core;
  @extend %core-orbiting;
  @include size(300px);
  @include revolution(2191);
  opacity: .7;
  border-color: transparent !important;
  overflow: hidden;
  &:before {
    @include size(210px);
    top: 50%;
    background: transparent;
    border-radius: 140px !important;
    box-shadow: stars(390, 290, -290 / 2, -104);
  }
}
.jupiter {
  @include planet(4332.589, 340px, 18px, #c76e2a);
}
.saturn {
  @include planet(10759.22, 440px, 12px, #e7c194);
  &:after {
    @include size(2.34%, 4.676%);
    @include revolution(10747, true); // true to compensate main orbit animation
    @include satellite();
    transform: rotateZ(-52deg);
    border-radius: 50%;
    box-shadow: 0 1px 0 1px #987641, 3px 1px 0 #987641, -3px 1px 0 #987641;
    transform-origin: 52% 60%;
  }
}
.uranus {
  @include planet(30685.4, 520px, 10px, #b5e3e3);
}
.neptune {
  @include planet(60189.0, 630px, 10px, #175e9e);
}
.pluto {
  @include planet(90560, 780px, 3px, #fff);
}

h1 {
  font-weight: 300;
  font-size: 2.5em;
  text-transform: uppercase;
  font-family: Lato;
  line-height: 1.6em;
  letter-spacing: .1em;
}

a, a:visited {
  text-decoration: none;
  color: white;
  opacity: .7;
  &:hover {
    opacity: 1;
  }
  &.icon {
    margin-right: 2px;
    padding: 3px;
  }
}

.description {
  padding: 30px;
  position: absolute;
  top: 0;
  left: 0;
  width: 25%;
  z-index: 999;
  p {
    font-size:.9em;
    & + p {
      margin-top: 20px;
    }
    &.author {
      font-size: .7em;
      .fa-heart {
        color: #860014;
      }
    }
    &.links {
      margin-top: 5px;
      font-size: 1em;
    }
  }
}

hr {
  margin: 26px 0;
  border: 0;
  border-top: 1px solid white;
  background: transparent;
  width: 25%;
  opacity: .1;
}

code {
  color: #ae94c0;
  font-family: Menlo, Monaco, Consolas, 'Courier New', monospace;
  font-size: .9em;
}

.hide {
  display: none;
}

            
          
!
            
              /*
  Malik Dellidj - @Dathink

  Solar System orbit animation true time scaled

  Revolution of planets in earth days (from Wikipedia)
  Mercury  : ~87.5 days
  Venus    : ~224.7 days
  Earth    : ~365.2563 days
    + Moon : ~27.3216 days (around earth)
  Mars     : ~687,days (~1,8 year)
  Jupiter  : ~4,331 days (~12 years)
  Saturn   : ~10,747 days (~30 years)
  Uranus   : ~30,589 days (~84 years)
  Neptune  : ~59,802 days (~165 years)
  Pluto    : ~90,580 days (~248 years)
*/

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console