Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                \<!--[if lte IE 9]>
:plain
  <style>
  #world, input, label {
    display: none !important;
  }
  </style>
  <h2>Please use IE 10+ to view this</h2>
<![endif]--> 
%input{:type=>'checkbox', :id=>'rise-button', :checked => 'checked', :class=>'show'}
%label{:for => 'rise-button'}
%input{:type=>'checkbox', :id => 'tower-1-button', :checked => 'checked', :class=>'tower-1'}  
%label{:for => 'tower-1-button'}
%input{:type=>'checkbox', :id => 'tower-2-button', :checked => 'checked', :class=>'tower-2'}
%label{:for => 'tower-2-button'}    
%input{:type=>'checkbox', :id => 'sunmoon-button', :checked => 'checked', :class=>'sunmoon'}
%label{:for => 'sunmoon-button'}
#world
  #sunmoon
  #towers    
    .clouds.back    
    .tower.south-east
      .path.north
        .path.west
        .path.north
    .tower.north-east
      .path.west.spire
        .spire-roof
        .path.west
          .path.west
            .path.west 
              .path.south
                .path.south
                  .path.east
                    .path.east
                      .path.east
                        .path.north
    .clouds.middle
    .tower.north-west
      .door
      .path.south.spire
        .spire-roof
        .path.east
          .path.east
            .path.east
    .tower.south-west       
      .path.north.spire
        .spire-roof
        .path.north
          
          .path.east
            .path.north
              .path.north
                .path.north
                  .path.north
                    .path.east
                      .path.east 
                        .path.east                        
                          .path.east
                            .path.east
                    .path.north.half-blocked-east
                      .path.north
                        .path.north
                          .path.west
                            .path.west
    .clouds.front
              
            
!

CSS

              
                @import "compass";
@import url(https://fonts.googleapis.com/css?family=Montserrat:700);

$mobile: "only screen and (max-width : 800px)";

$block: 60px;
$color: #88A;
$path-color: #999;
$roof-color: #933;
$tower-1-roof-color: #56D;
$tower-2-roof-color: #D67;
$tower-3-roof-color: #4D6;
$tower-4-roof-color: #665;
$tower-space: $block * 4;

body {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
}
#world { 
  width: 100%;
  height: 100%;
  position: fixed;
  background-color: #fcc6ff; // Old browsers
  @include filter-gradient(#fcc6ff, #bce1ff, vertical); // IE6-9
  @include background-image(linear-gradient(top, #fcc6ff 0%,#bce1ff 99%));
  @include transition(background-image 5s ease-in-out);
  @include display-flex;
  display: -ms-flexbox;
  @include flex-direction(column);
  -ms-flex-direction: column;
  @include align-items(center);
  -ms-align-items: center;
  @include justify-content(center);
  -ms-justify-content: center;
  text-align: center;
  &:before {
    position: absolute;
    top: 0px;
    left: 0px;
    content: '';
    width: 100%;
    height: 100%;
    opacity: 1;
    @include transition(opacity 3s ease-in-out);
    background-color: #004691; // Old browsers
    @include filter-gradient(#004691, #050056, vertical); // IE6-9
    @include background-image(linear-gradient(top, #004691 0%,#050056 100%));
  }
}

@mixin roof-color($roof-color) {
  border-bottom: $block / 2 * 2.6 solid mix(black, $roof-color, 50);    
  border-right: $block / 2 * 1.9 solid mix(white, $roof-color, 25);
  border-left: $block / 2 * 0.4 solid mix(black, $roof-color, 25);
  border-top: $block / 2 * 0.6 solid mix(white, $roof-color, 50);
}


h1 {
  position: relative;
  font-family: 'Montserrat', sans-serif;
  color: $color;
  margin: 1em 0;
}

#sunmoon {
  position: relative;
  display: block;
  top: 2 * $block;
  @include transition(transform 2s ease-in-out);
  @include transform-origin(0 0-$block);
  @include transform(rotateZ(0deg));
  // Before = sun, after == Creating the crescent moon
  &::before, &::after {
    display: block;
    border-radius: $block;
    content: ' ';
    position: absolute;    
    background: #FFF;
    width: $block * 2;
    height: $block * 2;
  }
  &::before {
    top: -4.5 * $block;
    left: -$block/2;
    background: none;
    box-shadow: $block/2 $block/2 0 0 #FFF;
  }
  &::after {
    top: 4 * $block;
  }
}

.sunmoon:checked ~ #world {
  &::before {
    opacity: 0;
  }
}
.sunmoon:checked ~ #world #sunmoon {
  @include transform(rotateZ(180deg) translateY(-2 * $block));
  
}
.sunmoon:not(:checked) ~ #world #sunmoon {
  @include transform(rotateZ(0deg) translateY(0px));
}

.tower-1:checked ~ #world #towers .tower.north-west {
  opacity: 0.5;
}

.tower-1:not(:checked) ~ #world #towers .tower.north-west {
}

.tower-2:checked~ #world #towers .tower.south-east {
}

.tower-2:not(:checked) ~ #world #towers .tower.south-east {
}

#towers {
  @include transform(scale(1, 0.7));
  width: $block * 10;
  height: $block * 6;
  position: relative;
}

.tower {
  
  
  
  width: $block;
  height: $block;
  position: absolute; 
  &::after, &::before {
    content: '';
    display: block;
    position: absolute;
    width: $block / 2 + 2;  // fudge. Why is this needed?
    height: $block * 6;
  }
  &::after {    
    left: $block / 2;
    top: $block;    
    @include transform-origin(0px, 0px);
    @include transform(skewY(-45deg));
    background: mix(white, $color, 25);
  }
  &::before {    
    top: $block;
    left: -2px; // fudge. Why is this needed?
    @include transform-origin($block / 2, 0px);
    @include transform(skewY(45deg));
    background: mix(black, $color, 25);
  }
  &.south-west {
    z-index: 3;
    bottom: 0px;
    left: $block/2;
    &::after, &::before {
      height: $block * 5;
    }  
    .spire-roof {      
      @include roof-color($tower-1-roof-color);
    }
  }  
  &.north-west {
    left: $block * 2 + 6; 
    top: 14px;
    &::after, &::before {
      height: $block * 8;
    }
    .spire-roof {      
      @include roof-color($tower-2-roof-color);
    }
  }  
  &.south-east { 
    right: $block * 2.666;
    bottom: $block * 2.666;
    z-index: 100;
    &::after, &::before {
      height: $block * 10;
    }
    .spire-roof {      
      @include roof-color($tower-3-roof-color);
    }
  }  
  &.north-east {
    // these numbers work. I don't know why...
    // Need to figure out the positioning of blocks and 
    // their relationship to the towers
    right: $block / 2 + 4; // fudge. why is this needed?
    top: $block / 4;
    .spire-roof {      
      @include roof-color($tower-4-roof-color);
    }
  }  
  
  // Align the path
  & > .path.spire {
    > .path {
      z-index: -1;
    }
    // target the first block in any path, i.e. the tower block
    background: mix(white, $color, 10);
    z-index: 10;
    &::before {
      top: -$block;
      left: -$block * 2;
      height: $block * 2;
      background: mix(black, $color, 25);
    }
    &::after {
      width: $block * 2;
      left: -$block;
      top: -$block * 4;
      background: mix(white, $color, 25);
    }
  }
  
  & > .path .path, & > .path:not(.spire) {    
    // target all other blocks
    background: mix(white, $path-color, 10);
  }
}

.show:checked {

  ~ #world #towers .tower {
    @include transition(transform 1s ease-out, opacity 2s ease-out);
  }
  ~ .tower-1:checked {
    ~ #world #towers .tower.north-west {
      @include transition-delay(0.1s);
      @include transform(translateY(0));
      opacity: 1;
    }
  }
  ~ .tower-1:not(:checked) {
    ~ #world #towers .tower.north-west {
      @include transition-delay(0.1s);
      @include transform(translateY(-126px));
      opacity: 1;
    }
  }
  
  ~ #world #towers .tower.north-east {
    @include transition-delay(0.45s);
    @include transform(translateY(0));
    opacity: 1;
  }
  ~ #world #towers .tower.south-west {
    @include transition-delay(0.8s);
    @include transform(translateY(0));
    opacity: 1;
  }
  
  ~ .tower-2:checked {
    ~ #world #towers .tower.south-east {
      @include transform(translateY(0));
      opacity: 1;
    }
  }
  ~ .tower-2:not(:checked) {
    ~ #world #towers .tower.south-east {
      @include transform(translateY(255px));
      opacity: 1;
    }
  }
  
  
  ~ #world #towers .tower .path {
    opacity: 1;
  }
}

.show:not(:checked) {
  
  ~ #world #towers .tower {
    @include transition(transform 1s ease-in, opacity 0.75s ease-in);
  }
  
  ~ #world #towers .tower.north-west {
    @include transition-delay(0.1s);
    @include transform(translateY(6 * $block));
    opacity: 0;
  }
  ~ #world #towers .tower.north-east {
    @include transition-delay(0.2s);
    @include transform(translateY(6 * $block));
    opacity: 0;
  }
  ~ #world #towers .tower.south-west {
    @include transition-delay(0.3s);
    @include transform(translateY(6 * $block));
    opacity: 0;
  }
  ~ #world #towers .tower.south-east {
    @include transition-delay(0.4s);
    @include transform(translateY(6 * $block));
    opacity: 0;
  }
  ~ #world #towers .tower .path {    
    opacity: 0;
  }
}

.path {
  
  @include transition(opacity 2s ease-out);
  
  position: absolute;
  top: 0px;
  
  &.south {
    z-index: 1;
  }
  
  &.east {
    z-index: 2;
  }
  
  &.north {
    z-index: 3;
  }
  
  // Blocks that are partially occluded by other blocks. Draw as
  // a "half-triangle"
  > .path.north > .path.west {
    &::before {
      height: 0;
      width: 0;
      background: none;
      border-right: 0;
      border-bottom: $block solid transparent;
      border-left: $block solid mix(black, $path-color, 25);;
    }
  }
  
  &.half-blocked-east {
    &::after {
      height: 0;
      width: 0;
      background: none;
      border-left: 0;
      border-right: $block solid transparent;
      border-top: $block solid mix(white, $path-color, 25);;
    }
  }
  
  >.north {
    &::before {
      background: none;
    }
  }
  
  >.west {
    &::after {
      background: none;
    }
  }
  
  &.to-east {
    &::after {
      background: none;
    }
  }
  
  &.to-south {
    &::before {
      background: none;
    }
  }

  //border:1px solid mix(black, $path-color, 25);
  
  width: $block; // allow for border size
  height: $block;
  
  box-shadow: inset 0px 0px 0px 15px mix(black, $path-color, 0.5);

  @include transform-origin(0px 0px);
  @include transform(rotateZ(45deg) scale(0.75));
  
  &::after, &::before {
    content: '';
    display: block;
    position: relative;
    width: $block;
    height: $block;
  }
  &::after {    
    left: $block;
    top: -$block;
    @include transform-origin(0px, 0px);
    @include transform(skewY(45deg));
    background: mix(white, $path-color, 25);
  }
  &::before {    
    top: $block;
    @include transform-origin($block / 2, 0px);
    @include transform(skewX(45deg));
    background: mix(black, $path-color, 25);
  }
  
  >.path.north {
    @include transform(translateY(-$block));
  }
  >.path.east {
    @include transform(translateX($block));
  }
  >.path.south {
    @include transform(translateY($block));
  }
  >.path.west {
    @include transform(translateX(-$block));
  }
}


.spire-roof {
    display: block;
    position: absolute;
    top: -$block * 2 * 1.1;
    left: -$block * 2;
    z-index: 200;
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
    //width: $block;
    //height: $block * 1.3;
    @include transform(rotateX(45deg));   
}

$cloud-letters: '\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663\2665\2663';

@include keyframes(clouds) {
  0% {
    @include transform(translateX(0px));
  }
  100% {
    @include transform(translateX(-2000px));
  }  
}

.clouds {
  // reverse the container scaling
  position: absolute;
  height: $block * 10;
  content: $cloud-letters;
  letter-spacing: -0.15em;
  color: #FFF;
  left: -1000px;
  width: 4000px;
  background: #FFF;
  font-size: 1em;
  $back-color: #DDD;
  $mid-color: #EEE;
  $front-color: #FFF;
  
  // General cloud layer
  &::after {
    content: $cloud-letters;
    display: block;
    position: absolute;
    font-size:1em;
    top: -0.6em;
    left:0px;
  }
  
  // Rear cloud layer
  &.back {
    @include animation(clouds 240s linear 0s infinite);
    z-index: -1;
    //background: #F88;
    //opacity: 0.5;
    background: $back-color;
    top: $block * 3;
  }
  &.back::after {
    color: $back-color;
    font-size: 14em;
  }
  
  // Middle cloud layer
  &.middle {
    z-index: 2;
    //background: #8F8;
    //opacity: 0.5;
    top: $block * 6;
    background: $mid-color;
    @include animation(clouds 180s linear 0s infinite);
  }
  &.middle::after {
    font-size: 18em;
    color: $mid-color;
  }
  
  // Front cloud layer
  &.front {
    z-index: 100;
    //background: #88F;
    top: $block * 10;
    background: $front-color;
    @include animation(clouds 60s linear 0s infinite);
    //opacity: 0.5;
  }
  &.front::after {
    font-size: 24em;
    color: $front-color;
  }
  &::after, &::before {
    letter-spacing: -0.125em;
  }
  
  
}


// Checkbox styling
input[type=checkbox] {
  position: absolute;
  z-index: 100;
  margin: 0.25em $block;
  height: $block/3;
  width: $block;
  +label {
    position: absolute;
    z-index: 101;
    display: block;
    margin: 0.25em $block;
    height: $block/3;
    width: $block;
    cursor: pointer;
    &::before {
      display: inline-block;
      position: relative;
      pointer-events: none;
      text-indent: 0.25em;
      text-align: center;

      font-size: 20px;
      height: $block/2;
      width: $block * 1.5;
      line-height: $block/2;
      @media #{$mobile} {
        font-size: 26px;
        height: $block;
        width: $block * 2;
        line-height: $block;
      }

      font-family: 'Montserrat', sans-serif;
      background: #777;
      border-radius: 5px;
      @include transition(background 0.25s ease-in-out, color 0.5s ease-in-out);
      top: -$block/6;
      left: -$block/6;
    }
  }
  &.show {
    top: 100px;
    @media #{$mobile} {
      top: 10px;
    }
    + label {
      top: 100px;
      @media #{$mobile} {
        top: 10px;
      }
      &::before {      
        content: 'rise';
        background: #dde;
      }
    }
    &:checked +label::before {
      content: 'fall';
      background: #466;
      color: #222;
    } 
    
  }


  &.tower-1 {
    
    top: 100px + ($block / 2);
    @media #{$mobile} {
      top: 10px + ($block);
    }
    + label{
     top: 100px + ($block / 2);
        @media #{$mobile} {
          top: 10px + ($block);
        }
      &::before {      
        content: 'up';
        background: $tower-2-roof-color;
      }
    }
    &:checked +label::before {
      content: 'down';
      background: mix(black, $tower-2-roof-color, 25);
    }
  }
  &.tower-2 {
    top: 100px + ($block / 2) * 2;
    @media #{$mobile} {
      top: 10px + ($block * 2);
    }
    + label {
      top: 100px + ($block / 2) * 2;
      @media #{$mobile} {
        top: 10px + ($block * 2);
      }
      &::before {      
        content: 'down';
        background: $tower-4-roof-color;
      }
    }
    &:checked +label::before {
      content: 'up';
      background: mix(black, $tower-4-roof-color, 25);      
    }
  }
  &.sunmoon {
    top: 100px + ($block / 2) * 3;
    @media #{$mobile} {
      top: 10px + ($block * 3);
    }
    + label {
      top: 100px + ($block / 2) * 3;
      @media #{$mobile} {
        top: 10px + ($block * 3);
      }
      &::before {      
        content: 'night';
        background: #001C37;
        color: #FFF;
      }
    }
    &:checked +label::before {
      content: 'day';
      background: #CC99FF;
      color: #000;
    }
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console