css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              mixin structure()
  each val in [1, 2, 3, 4, 5, 6]
    div(class="planet__structure planet__structure--" + val)
  
  
mixin planet(planetname)
  div(class=planetname + "-orbit sun-orbit")
    div(class="ascending-node ascending-node--" + planetname)
      div(class="inclination inclination--" + planetname)
        .orbit__visual
        div(class="orbit__shape orbit__shape--" + planetname)
          div(class="planet " + planetname)
            +structure
          block
          
input(type="radio" id="correct-orbit-size" name="orbit-size")
input(type="radio" id="ideal-orbit-size" name="orbit-size" checked)
input(type="radio" id="real-time" name="velocity")
input(type="radio" id="one-year-per-minute" name="velocity" checked)
input(type="radio" id="one-year-per-second" name="velocity")
input(type="radio" id="topview" name="perspective")
input(type="radio" id="isometric" name="perspective")
input(type="radio" id="threedee" name="perspective" checked)
.universe
  .solarsystem
    .sun
      +structure
    +planet("mercury")
    +planet("venus")
    +planet("earth")
    +planet("mars")
    +planet("jupiter")
    +planet("saturn")
      .planet-orbit.planet-orbit--saturn
        .rings-of-saturn 
    +planet("uranus") 
    +planet("neptun")

.content
  h1 The Solar System
  .controls
    .controls__group
      span Orbit Size:
      label(for="correct-orbit-size" class="button correct-size") Correct
      label(for="ideal-orbit-size" class="button ideal-size") Idealized
      
    .controls__group
      span Velocity:
      label(for="real-time" class="button real-time") Realtime
      label(for="one-year-per-minute" class="button one-year-per-minute") 1 Year / Min
      label(for="one-year-per-second" class="button one-year-per-second") 1 Year / Sec
      
    .controls__group
      span Perspective:
      label(for="threedee" class="button threedee") 3d
      label(for="topview" class="button topview") Top
      label(for="isometric" class="button isometric") Isometric
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Montserrat:300,400')

html
  font-size 16px
  background-color black
  
#ideal-orbit-size ~ .universe
  --planet-size-factor 0.01
  --sun-size-factor 0.001
  
#ideal-orbit-size:checked ~ .universe
  @media (max-width: 649px)
    --planet-size-factor 0.075
    --sun-size-factor 0.0175
    
  @media (min-width: 650px)
    --planet-size-factor 0.15
    --sun-size-factor 0.025
    
#real-time:checked ~ .universe
  --speed-of-animation 1
  
#one-year-per-minute:checked ~ .universe
  --speed-of-animation 518400
  
#one-year-per-second:checked ~ .universe
  --speed-of-animation 31104000
  
#topview ~ .universe
  --topview -65deg
  --angle-sun-glow 65deg
  
#topview:checked ~ .universe
  --topview 0deg
  --angle-sun-glow 0deg
  
#isometric ~ .universe
  --perspective 750px
  
#isometric:checked ~ .universe
  --perspective 10000px
  
.universe
  --orbit-size-factor 1000000
  position absolute
  top 0
  left 0
  right 0
  bottom 0
  background radial-gradient(#020311 0%, black 100%)
  display flex
  justify-content center
  align-items center
  overflow hidden
  perspective var(--perspective)
  transition perspective 2s
  
.solarsystem
  position relative
  width 90%
  max-width 100vh
  display flex
  justify-content center
  align-items center
  transform rotateZ(90deg) rotateY(var(--topview))
  transform-style preserve-3d
  transition transform 2s
  
  &::after
    display block
    content ""
    width 100%
    padding-top 100%
    border-radius 50%
    
.sun
  position absolute
  width calc(1391px * var(--sun-size-factor))
  height calc(1391px * var(--sun-size-factor))
  background-color #ffe493
  border-radius 50%
  transform-style preserve-3d
  transition width 2s, height 2s
  
  &::before
    display block
    content ""
    height 600%
    width 600%
    background radial-gradient(rgba(255, 228, 147, 0.4), rgba(255, 228, 147, 0.1) 40%, rgba(255,255,255,0) 70%)
    border-radius 50%
    transform-origin center center
    transform  translateY(-40%) translateX(-40%) rotateY(var(--angle-sun-glow))
    transition transform 2s
  
#ideal-orbit-size:checked ~ .universe .sun
  transition-delay 0.6s

// ORBITS
.sun-orbit
  transform-style preserve-3d
  border-radius 50%
  transition width 2s, height 2s
    
.mercury-orbit
  position absolute
  width 1.29%
  height 1.29%
  transform rotateZ(-224deg)
  transition-delay 0s
  z-index 9
  
#ideal-orbit-size:checked ~ .universe .mercury-orbit
  width 12.5%
  height 12.5%
  transition-delay 0.6s
  
.venus-orbit
  position absolute
  width 2.4%
  height 2.4%
  transform rotateZ(-144deg)
  transition-delay 0.1s
  z-index 8
  
#ideal-orbit-size:checked ~ .universe .venus-orbit
  width 25%
  height 25%
  transition-delay 0.5s
    
.earth-orbit
  position absolute
  width 3.33%
  height 3.33%
  transform rotateZ(-101deg)
  transition-delay 0.2s
  z-index 7
  
#ideal-orbit-size:checked ~ .universe .earth-orbit
  width 37.5%
  height 37.5%
  transition-delay 0.4s
  
.mars-orbit
  position absolute
  width 5.06%
  height 5.06%
  transform rotateZ(-39deg)
  transition-delay 0.3s
  z-index 6
  
#ideal-orbit-size:checked ~ .universe .mars-orbit
  width 50%
  height 50%
  transition-delay 0.3s
  
.jupiter-orbit
  position absolute
  width 17.25%
  height 17.25%
  transform rotateZ(-245deg)
  transition-delay 0.4s
  z-index 5
  
#ideal-orbit-size:checked ~ .universe .jupiter-orbit
  width 62.5%
  height 62.5%
  transition-delay 0.2s
  
.saturn-orbit
  position absolute
  width 31.65%
  height 31.65%
  transform rotateZ(-282deg)
  transition-delay 0.5s
  z-index 4
  
#ideal-orbit-size:checked ~ .universe .saturn-orbit
  width 75%
  height 75%
  transition-delay 0.1s
  
.uranus-orbit
  position absolute
  width 63.96%
  height 63.96%
  transform rotateZ(-29deg)
  transition-delay 0.6s
  z-index 3
  
#ideal-orbit-size:checked ~ .universe .uranus-orbit
  width 87.5%
  height 87.5%
  transition-delay 0s
  
.neptun-orbit
  position absolute
  width 100%
  height 100%
  transform rotateZ(-347deg)
  z-index 2

.orbit__visual
  position absolute
  border 1px solid rgba(255,255,255,0.13)
  width 100%
  height 100%
  border-radius 50%
  transform translate3d(-1px, -1px, 0)
  transform-style preserve-3d
  
.orbit__shape
  position absolute
  width calc(100% + 1px)
  height calc(100% + 1px)
  animation orbit infinite
  animation-timing-function linear
  animation-delay calc((var(--seconds-left)  * -1) / var(--speed-of-animation))
  transform-style preserve-3d
  
  &--mercury
    animation-duration calc(7603200s / var(--speed-of-animation))
  &--venus
    animation-duration calc(19414166s / var(--speed-of-animation))
  &--earth
    animation-duration calc(31553280s / var(--speed-of-animation))
  &--mars
    animation-duration calc(59356800s / var(--speed-of-animation))
  &--jupiter
    animation-duration calc(374025600s / var(--speed-of-animation))
  &--saturn
    animation-duration calc(928886400s / var(--speed-of-animation))
  &--uranus
    animation-duration calc(2649369600s / var(--speed-of-animation))
  &--neptun
    animation-duration calc(5196787200s / var(--speed-of-animation))

// PLANETS
.planet 
  position relative
  border-radius 50%
  min-width 1px
  min-height 1px
  margin 0 auto
  left 0
  right 0
  transform-style preserve-3d
  transition width 2s, height 2s, top 2s
    
  &::before
    position relative
    display none
    content ""
    height 500%
    transform translateY(-100%)
    width 100%
    background linear-gradient(to top, rgba(1,2,13,0.8), rgba(1,2,13,0) 100%)
    clip-path: polygon(50% 0%, 100% 100%, 100% 100%, 0% 100%);
    
  &__structure
    position absolute
    top 0
    left 0
    width 100%
    height 100%
    background-color inherit
    border-radius 50%
    transform-style preserve-3d
    
    &--1
      transform rotateZ(30deg)
      
    &--2
      transform rotateZ(-30deg)
      
    &--3
      transform rotateX(30deg) rotateY(90deg)
      
    &--4
      transform rotateX(-30deg) rotateY(90deg)
      
    &--5
      transform rotateZ(90deg) rotateY(30deg)
      
    &--6
      transform rotateZ(90deg) rotateY(-30deg)
    
    &::before
      position absolute
      top 0
      content ""
      display block
      width 100%
      height 100%
      transform rotateX(45deg)
      background-color inherit
      border-radius 50%
      
    &::after
      position absolute
      top 0
      content ""
      display block
      width 100%
      height 100%
      transform rotateX(-45deg)
      background-color inherit
      border-radius 50%
    
.mercury
  width calc(4.87px * var(--planet-size-factor))
  height calc(4.87px * var(--planet-size-factor))
  background-color #68696D
  top calc(-2.435px * var(--planet-size-factor))
    
.venus
  width calc(12.10px * var(--planet-size-factor))
  height calc(12.10px * var(--planet-size-factor))
  background-color #d3a567
  top calc(-6.05px * var(--planet-size-factor))
  
.earth
  width calc(12.70px * var(--planet-size-factor))
  height calc(12.70px * var(--planet-size-factor))
  background-color blue
  top calc(-6.35px * var(--planet-size-factor))
  
.mars
  width calc(6.70px * var(--planet-size-factor))
  height calc(6.70px * var(--planet-size-factor))
  background-color #C1440E
  top calc(-3.45px * var(--planet-size-factor))
  
.jupiter
  width calc(139.822px * var(--planet-size-factor))
  height calc(139.822px * var(--planet-size-factor))
  background-color #d8ca9d
  top calc(-69.911px * var(--planet-size-factor))
  
.saturn
  width calc(116.464px * var(--planet-size-factor))
  height calc(116.464px * var(--planet-size-factor))
  background-color #D2C0A5
  top calc(-58.232px * var(--planet-size-factor))
  
.uranus
  width calc(50.724px * var(--planet-size-factor))
  height calc(50.724px * var(--planet-size-factor))
  background-color #d1e7e7
  top calc(-25.362px * var(--planet-size-factor))
  
.neptun
  width calc(49.244px * var(--planet-size-factor))
  height calc(49.244px * var(--planet-size-factor))
  background-color #3f54ba
  top calc(-24.622px * var(--planet-size-factor))
  
.planet-orbit
  animation orbit infinite
  animation-timing-function linear
  transform-style preserve-3d
  top 0
  left 0
  right 0
  position absolute
  
  &--saturn
    animation-duration calc(933465600s / var(--speed-of-animation))
    animation-delay calc(((var(--seconds-left) + 433366400) * -1) / var(--speed-of-animation))
  
.rings-of-saturn
  transform rotateX(0deg) rotateY(27deg)
  position absolute
  width calc(280px * var(--planet-size-factor) + 3px)
  height calc(280px * var(--planet-size-factor) + 3px)
  background radial-gradient(rgba(0,0,0,0), rgba(0,0,0,0) 45%, #c1b199 48%, #c1b199 65%, rgba(0,0,0,0) 66%, #c1b199 68%, #c1b199 100%)
  top calc(-140px * var(--planet-size-factor) - 1.5px)
  border-radius 50%
  margin 0 auto
  left 0
  right 0
  transition width 2s, height 2s, top 2s
  
// ASTROMECHANICS
.ascending-node
  position relative
  height 100%
  transform-style preserve-3d
  
  /*&--mercury
    transform rotateZ(48.33deg)
  &--venus
    transform rotateZ(76.68deg)
  &--earth
    transform rotateZ(-11.26deg)
  &--mars
    transform rotateZ(49.58deg)
  &--jupiter
    transform rotateZ(100.55deg)
  &--saturn
    transform rotateZ(113.72deg)
  &--uranus
    transform rotateZ(74.23deg)
  &--neptun
    transform rotateZ(131.72deg)*/
  
.inclination
  position relative
  height 100%
  transform-style preserve-3d
  
  /*&--mercury
    transform rotateX(-7deg)
  &--venus
    transform rotateX(-3.5deg)
  &--earth
    transform rotateX(0deg)
  &--mars
    transform rotateX(-1.9deg)
  &--jupiter
    transform rotateX(-1.3deg)
  &--saturn
    transform rotateX(-2.5deg)
  &--uranus
    transform rotateX(-0.8deg)
  &--neptun
    transform rotateX(-1.8deg)*/
    
@keyframes orbit {
  from {
    transform rotate(360deg)
  }
  
  to {
    transform rotate(0deg)
  }
}

.content
  color white
  width 100%
  height 100%
  font-size 16px
  top 0
  left 0
  position absolute
  font-family Open Sans, sans-serif
  text-align center
  
  
  h1   
    font-weight 300
    text-transform uppercase
    font-family: 'Montserrat', sans-serif;
    letter-spacing 15px
    
.controls
  @media (max-width: 649px)
    position absolute
    bottom 0

  @media (min-width: 650px)
    display inline-block 
    
  justify-content center
  font-weight 300
  letter-spacing 1px
  font-size 13px
  max-width 600px
  width 100%

  span
    width 120px
  
  &__group
    border-radius 10px
    border 1px solid rgba(255, 255, 255, 0.7)
    display flex
    flex 1
    margin-bottom 15px
    
    > *
      padding 10px
      display block
    
.button
  flex 1
  transition background-color 0.4s
  text-transform uppercase
  user-select none
    
  &:hover
    background-color rgba(255, 255, 255, 0.2)
    
  &:first-of-type
    border-radius 9px 0 0 9px
    
  &:last-child
    border-radius 0 9px 9px 0

#ideal-orbit-size:checked ~ .content .button.ideal-size
#correct-orbit-size:checked ~ .content .button.correct-size
#real-time:checked ~ .content .button.real-time
#one-year-per-minute:checked ~ .content .button.one-year-per-minute
#one-year-per-second:checked ~ .content .button.one-year-per-second
#topview:checked ~ .content .button.topview
#isometric:checked ~ .content .button.isometric
#threedee:checked ~ .content .button.threedee
  background-color rgba(255, 255, 255, 0.3)
            
          
!
            
              //For those who wonder why Javascript is here, a short explanation. This script only ensures that the initial position, the planetary position is calculated correctly by setting the seconds left since 1-1-2019 to a css custom variable. No hidden Magic 🤷

let timestamp_start = new Date("2019-01-01").getTime();
let timestamp_now = new Date().getTime();
let secondsLeft = (timestamp_now - timestamp_start) / 1000;
let root = document.documentElement;
root.style.setProperty('--seconds-left', `${secondsLeft}s`);
            
          
!
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.
Loading ..................

Console