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

              
                mixin cameras
  .container
    - for (i = 0; i < 441; i++)
      .trigger
    .monitor
      .camera.-z
        .camera.-y
          .camera.-x
            block

+cameras
  .train-art
    .background-section
      .sky
      .sun
      .pole
    .floor-section
      .panel
    .back-section
      .screens
        .screen.-top
        .screen.-left
        .screen.-right
        .screen.-bottom
      .body
        .panel.-top
        .panel.-windowleft
        .panel.-windowright
        .panel.-windowbottom
        .panel.-bottomleft
        .panel.-bottomright
        .panel.-doorleft
        .windowthickness.-top
        .windowthickness.-left
        .windowthickness.-right
        .windowthickness.-bottom
        .bodythickness.-left
        .bodythickness.-right
        .doorpocket.-left
        .doorpocket.-right
        .doorpocket.-top
        .doorpocket.-bottom
      .doors
        .door.-left
          .panel.-top
          .panel.-bottom
          .panel.-left
          .panel.-right
          .panel.-doorbottom
          .thickness.-top
          .thickness.-left
          .thickness.-right
          .thickness.-bottom
        .door.-right
          .panel.-top
          .panel.-bottom
          .panel.-left
          .panel.-right
          .panel.-doorbottom
          .thickness.-top
          .thickness.-left
          .thickness.-right
          .thickness.-bottom
    .ceiling-section
      .panel
    .seat-section
      .side.-left
      .side.-right
      .seat
        .cussion.-top
        .cussion.-back
        .cussion.-backtop
        .cussion.-front
        .cussion.-bottom
        .mecha.-front
        .mecha.-bottom
        .shadow
    .info-section
      .panel.-top
      .panel.-front
      .panel.-left
      .panel.-right
    .shelf-section
      .pillar.-left
      .pillar.-right
      .pillar.-center
      .arm.-left
      .arm.-right
      .arm.-center
      .line.-line1
      .line.-line2
      .line.-line3
      .line.-line4
      .line.-line5
    .strap-section
      .arm
      .pillar.-pillar1
      .pillar.-pillar2
      .pillar.-pillar3
      .pillar.-pillar4
      .pillar.-pillar5
      .strap-parts
        - for (i = 0; i < 16; i++)
          .strap
            .shake
              .joint
              .belt
              .handle
              
            
!

CSS

              
                // Custom param *** START
$power: 5;
$defaultRotateX: 0;
$defaultRotateY: 0;
$defaultRotateZ: 0;
$perspective: 500px;
// Custom param *** END

// Your world *** START
body {
  background: #000;
}

.train-art {
  transform: translate(-250px, -100px);
}

.background-section {
  .sky {
    top: -300px;
    left: -1000px;
    width: 2500px;
    height: 800px;
    background: linear-gradient(to bottom, #FFC371, #FF5F6D);
    transform: translate3d(0, 0, -500px);
  }
  
  .sun {
    width: 50px;
    height: 50px;
    background: #ff0;
    border-radius: 100%;
    transform: translate3d(250px, -50px, -500px);
    filter: drop-shadow(0 0 20px #ff0) blur(2px);
  }
  
  .pole {
    top: -300px;
    width: 20px;
    height: 800px;
    background: linear-gradient(90deg, #444, #000);
    transform: translate3d(0, 0, -200px);
    animation: pole 2000ms linear infinite;
  }
}

@keyframes pole {
  0% {
    transform: translate3d(-500px, 0, -200px);
  }
  
  50% {
    transform: translate3d(1000px, 0, -200px);
  }
  
  100% {
    transform: translate3d(1000px, 0, -200px);
  }
}

.back-section {
  .screen {
    background: #000;

    &.-top {
      left: -500px;
      top: -500px;
      width: 1500px;
      height: 500px;
      transform: translate3d(0, 0, -110px);
    }
    
    &.-bottom {
      left: -500px;
      top: 200px;
      width: 1500px;
      height: 500px;
      transform: translate3d(0, 0, -110px);
    }
    
    &.-left {
      left: -500px;
      top: -500px;
      width: 500px;
      height: 1200px;
      transform: translate3d(0, 0, -110px);
    }
    
    &.-right {
      left: 500px;
      top: -500px;
      width: 500px;
      height: 1200px;
      transform: translate3d(0, 0, -110px);
    }
  }
  .body {
    .panel {
      backface-visibility: hidden;

      &.-top {
        width: 500px;
        height: 40px;
        background: #e7e3d9;
        transform: translateZ(-100px);
      }

      &.-windowleft {
        width: 70px;
        height: 200px;
        background: #e7e3d9;
        transform: translate3d(150px, 0, -100px);
      }

      &.-windowright {
        width: 40px;
        height: 200px;
        background: #e7e3d9;
        transform: translate3d(460px, 0, -100px);
      }

      &.-windowbottom {
        width: 330px;
        height: 80px;
        background: #e7e3d9;
        transform: translate3d(170px, 120px, -100px);
      }

      &.-doorleft {
        width: 30px;
        height: 200px;
        background: #e7e3d9;
        transform: translate3d(0, 0, -100px);
      }
      
      &.-bottomleft {
        width: 30px;
        height: 10px;
        background: #c3bca6;
        transform: translate3d(0, 195px, -105px) rotateX(-90deg);
      }
      
      &.-bottomright {
        width: 350px;
        height: 10px;
        background: #c3bca6;
        transform: translate3d(150px, 195px, -105px) rotateX(-90deg);
      }
    }
    
    .windowthickness {
      backface-visibility: hidden;

      &.-top {
        width: 240px;
        height: 10px;
        background: #b8b2a4;
        transform: translate3d(220px, 35px, -105px) rotateX(-90deg);
      }
      
      &.-bottom {
        width: 240px;
        height: 10px;
        background: #f2ecdd;
        transform: translate3d(220px, 115px, -105px) rotateX(90deg);
      }
      
      &.-left {
        width: 10px;
        height: 80px;
        background: #d7cfbe;
        transform: translate3d(215px, 40px, -105px) rotateY(90deg);
      }
      
      &.-right {
        width: 10px;
        height: 80px;
        background: #d7cfbe;
        transform: translate3d(455px, 40px, -105px) rotateY(-90deg);
      }
    }
    
    .bodythickness {
      backface-visibility: hidden;
      
      &.-left {
        width: 10px;
        height: 200px;
        background: #d7cfbe;
        transform: translate3d(-5px, 0, -105px) rotateY(-90deg);
      }
      
      &.-right {
        width: 10px;
        height: 200px;
        background: #d7cfbe;
        transform: translate3d(495px, 0, -105px) rotateY(90deg);
      }
    }
  }
  
  .door {
    &.-left {
      transform: translate3d(30px, 40px, -100px);
    }
    
    &.-right {
      transform: translate3d(90px, 40px, -100px);
    }
    
    .panel {
      background: #ccc;
      background: linear-gradient(180deg, #c0c0c0 0, #f2f2f2 60px, #c0c0c0 120px);
      backface-visibility: hidden;

      &.-top {
        width: 60px;
        height: 10px;
      }

      &.-left {
        width: 10px;
        height: 160px;
      }

      &.-right {
        width: 10px;
        height: 160px;
        transform: translateX(50px);
      }

      &.-bottom {
        width: 60px;
        height: 160px;
        clip-path: polygon(0 80px, 100% 80px, 100% 105%, 0 105%);
      }
      
      &.-doorbottom {
        width: 60px;
        height: 4px;
        background: #999;
        transform: translate3d(0, 158px, -2px) rotateX(-90deg);
      }
    }
    
    .thickness {
      backface-visibility: hidden;

      &.-top {
        width: 40px;
        height: 4px;
        background: #888;
        transform: translate3d(10px, 8px, -2px) rotateX(-90deg);
      }
      
      &.-bottom {
        width: 40px;
        height: 4px;
        background: #ddd;
        transform: translate3d(10px, 78px, -2px) rotateX(90deg);
      }
      
      &.-left {
        width: 4px;
        height: 70px;
        background: #aaa;
        transform: translate3d(8px, 10px, -2px) rotateY(90deg);
      }
      
      &.-right {
        width: 4px;
        height: 70px;
        background: #aaa;
        transform: translate3d(48px, 10px, -2px) rotateY(-90deg);
      }
    }
  }
  
  .doors {
    transform: translate3d(0, 0, -2px);
  }
  
  .doorpocket {    
    &.-top {
      width: 120px;
      height: 10px;
      background: #3b3a36;
      transform: translate3d(30px, 35px, -105px) rotateX(-90deg);
      backface-visibility: hidden;
    }
    
    &.-bottom {
      width: 120px;
      height: 10px;
      background: #3b3a36;
      transform: translate3d(30px, 195px, -105px) rotateX(90deg);
    }
    
    &.-left {
      width: 10px;
      height: 160px;
      background: #65625a;
      transform: translate3d(25px, 40px, -105px) rotateY(90deg);
      backface-visibility: hidden;
    }
    
    &.-right {
      width: 10px;
      height: 160px;
      background: #65625a;
      transform: translate3d(145px, 40px, -105px) rotateY(-90deg);
      backface-visibility: hidden;
    }
  }
}

.floor-section {
  .panel {
    width: 500px;
    height: 140px;
    background: repeating-radial-gradient(ellipse at right top, rgba(#fff, 0) 0, rgba(#fff, 0.02) 10px), linear-gradient(0deg, #c1c2c6, #a2a29e);
    transform: translate3d(0px, 130px, -30px) rotateX(90deg);
    backface-visibility: hidden;
  }
}

.ceiling-section {
  .panel {
    width: 500px;
    height: 140px;
    background: linear-gradient(0deg, #afaca4, #bebbb5);
    transform: translate3d(0px, -70px, -30px) rotateX(-90deg);
    backface-visibility: hidden;
  }
}

.seat-section {
  .cussion {
    backface-visibility: hidden;

    &.-back {
      width: 320px;
      height: 44px;
      background: linear-gradient(180deg, rgba(#26294f, 1) 0%, rgba(#5163a6, 0) 50%, rgba(#5163a6, 0.5) 100%), repeating-linear-gradient(90deg, #313a65 0, #26294f 10px, #26294f 30px, #313a65 40px);
      transform: translate3d(180px, 129.7px, -87px) rotateX(10deg);
    }

    &.-backtop {
      width: 320px;
      height: 10px;
      background: #2c2f57;
      transform: translate3d(180px, 125px, -95px) rotateX(90deg);
    }
    
    &.-top {
      width: 320px;
      height: 40px;
      background: linear-gradient(180deg, rgba(#26294f, 1) 0%, rgba(#5163a6, 0) 50%, rgba(#5163a6, 0.5) 100%), repeating-linear-gradient(90deg, #313a65 0, #26294f 10px, #26294f 30px, #313a65 40px);
      transform: translate3d(180px, 150px, -65px) rotateX(90deg);
    }
    
    &.-front {
      width: 320px;
      height: 10px;
      background: linear-gradient(0deg, rgba(#5163a6, 0) 50%, rgba(#5163a6, 0.5) 100%), repeating-linear-gradient(90deg, #313a65 0, #26294f 10px, #26294f 30px, #313a65 40px);
      transform: translate3d(180px, 170px, -45px);
    }
    
    &.-bottom {
      width: 320px;
      height: 10px;
      background:#26294f;
      transform: translate3d(180px, 175px, -50px) rotateX(-90deg);
    }
  }
  
  .mecha {
    &.-front {
      width: 320px;
      height: 22.3px;
      background: repeating-linear-gradient(90deg, #666 0, #666 1px, rgba(#000, 0) 1.1px, rgba(#000, 0) 1.3px), repeating-linear-gradient(0deg, #666 0, #666 1px, #000 2px, #000 3px);
      transform: translate3d(180px, 179px, -59px) rotateX(-22deg);
      backface-visibility: hidden;
      border: 3px solid #666;
      box-sizing: border-box;
      
      &::after {
        content: '';
        position: absolute;
        top: -3px;
        left: -3px;
        width: calc(100% + 6px);
        height: calc(100% + 6px);
        background: linear-gradient(0deg, rgba(#fff, 0.4), rgba(#fff, 0) 60%);
      }
      
      &::before {
        content: '';
        position: absolute;
        left: calc(50% - 3px);
        width: 6px;
        height: 100%;
        background: #666;
      }
    }
    
    &.-bottom {
      width: 320px;
      height: 37px;
      background: #222;
      transform: translate3d(180px, 181.6px, -82px) rotateX(-90deg);
      backface-visibility: hidden;
    }
  }
  
  .shadow {
    width: 320px;
    height: 30px;
    background: linear-gradient(0deg, rgba(#000, 0), rgba(#000, 0.1), rgba(#000, 0.3));
    transform: translate3d(180px, 185px, -50px) rotateX(90deg);
    backface-visibility: hidden;
  }
  
  .side {
    width: 60px;
    height: 100px;
    background: radial-gradient(ellipse at left top, rgba(#fff, 1), rgba(#ccc, 1));
    border-radius: 80% 0 0 0;
    
    &.-left {
      transform: translate3d(150px, 100px, -70px) rotateY(90deg);
    }
    
    &.-right {
      transform: translate3d(470px, 100px, -70px) rotateY(90deg);
    }
  }
}

.info-section {
  .panel {
    backface-visibility: hidden;
    
    &.-top {
      width: 500px;
      height: 31px;
      background: #fff;
      transform: translate3d(0, -15.5px, -94.4px) rotateX(90deg);
    }
    
    &.-front {
      width: 500px;
      height: 30px;
      background: linear-gradient(0deg, #d1cdc4, #bfbbb2);
      transform: translate3d(0, -4.5px, -89.4px) rotateX(-45deg);
    }
    
    &.-left {
      width: 21px;
      height: 21.5px;
      background: #d7cfbe;
      clip-path: polygon(0 0, 100% 0, 0 100%);
      transform: translate3d(-10.5px, 0, -90px) rotateY(-90deg);
    }
    
    &.-right {
      width: 21px;
      height: 21.5px;
      background: #d7cfbe;
      clip-path: polygon(0 0, 100% 0, 100% 100%);
      transform: translate3d(489.5px, 0, -90px) rotateY(90deg);
    }
  }
}

.shelf-section {
  .pillar {
    width: 4px;
    height: 110px;
    background-image: linear-gradient(0deg, rgba(#555, 1), rgba(#555, 0)), linear-gradient(90deg, #555, #fff);
    border-radius: 99px;
    
    &.-left {
      transform: translate3d(178px, 34px, -45px) rotateY(90deg) rotateZ(10deg);
    }
    
    &.-right {
      transform: translate3d(498px, 34px, -45px) rotateY(90deg) rotateZ(10deg);
    }
    
    &::before {
      content: '';
      position: absolute;
      bottom: -12px;
      width: 100%;
      height: 15px;
      border-radius: 99px;
      background: #555;
      transform-origin: 50% 2px;
      transform: rotateZ(-50deg);
    }
    
    &.-center {
      height: 145px;
      transform: translate3d(338px, 34px, -42px) rotateY(90deg) rotateZ(10deg);
      
      &::before {
        bottom: -37px;
        height: 40px;
        transform: rotateZ(-80deg);
      }
    }
  }
  
  .line {
    width: 320px;
    height: 3px;
    background: linear-gradient(0deg, #555, #fff);
    
    &.-line1 {
      transform: translate3d(180px, 35px, -55px);
    }
    
    &.-line2 {
      transform: translate3d(180px, 35px, -63px);
    }
    
    &.-line3 {
      transform: translate3d(180px, 35px, -71px);
    }
    
    &.-line4 {
      transform: translate3d(180px, 35px, -79px);
    }
    
    &.-line5 {
      transform: translate3d(180px, 35px, -88px);
    }
    
    &.-line6 {
      transform: translate3d(180px, 35px, -87px);
    }
  }
  
  .arm {
    width: 50px;
    height: 3px;
    background: linear-gradient(0deg, #555, #fff);
    
    &.-left {
      transform: translate3d(155px, 35px, -80px) rotateY(90deg);
    }
    
    &.-right {
      transform: translate3d(475px, 35px, -80px) rotateY(90deg);
    }
    
    &.-center {
      transform: translate3d(312px, 35px, -80px) rotateY(90deg);
    }
  }
}

.strap-section {
  .arm {
    width: 500px;
    height: 3px;
    background: linear-gradient(0deg, #555, #fff);
    transform: translate3d(0, 15px, -20px);
  }
  
  .pillar {
    width: 3px;
    height: 15px;
    background: linear-gradient(-90deg, #555, #fff);
    
    @for $i from 1 through 5 {
      &.-pillar#{$i} {
        transform: translate3d(($i - 1) * 100px + 10px, 0, -20px);
      }
    }
    
    &::before {
      content: '';
      position: absolute;
      width: 5px;
      height: 5px;
      background: #888;
      border-radius: 100%;
      transform: translate3d(-1px, -2.5px, 0) rotateX(90deg);
    }
  }
  
  .joint {
    width: 3px;
    height: 5px;
    border: 1px solid #ccc;
    border-radius: 100% 100% 0 0;
  }
  
  .belt {
    width: 5px;
    height: 10px;
    background: linear-gradient(0deg, #ccc, #eee);
    transform: translate3d(0, 6px, 0);
  }
  
  .handle {
    width: 9px;
    height: 9px;
    border: 2px solid #fff;
    border-radius: 100%;
    transform: translate3d(-4px, 15px, 0);
    
    &::before {
      content: '';
      position: absolute;
      top: -2px;
      left: -2px;
      width: calc(100% + 4px);
      height: calc(100% + 4px);
      border-radius: 100%;
      border: 2px double rgba(#000, 0.1);
      box-sizing: border-box;
    }
  }
  
  .strap {
    @for $i from 1 through 30 {
      &:nth-child(#{$i}) {
        transform: translate3d($i * 30px - 5px, 14px, -17px) rotateY(90deg);
        
        .shake {
          animation-delay: random(100) * -1ms;
        }
      }
    }
    
    &:nth-child(n + 7) {
      .belt {
        height: 20px;
      }
      
      .handle {
        bottom: -22px;
      }
    }
  }
  
  .shake {
    transform: rotateX(30deg);
    animation: shake 1500ms ease-in-out infinite alternate;
    transform-origin: 3px 1px;
  }
}

@keyframes shake {
  0% {
    transform: rotateZ(-10deg);
  }
  
  30% {
    transform: rotateZ(5deg);
  }
  
  60% {
    transform: rotateZ(-5deg);
  }
  
  100% {
    transform: rotateZ(10deg);
  }
}
// Your world *** END

// Template *** START
div {
  position: absolute;
  transform-style: preserve-3d;
}

body {
  display: grid;
  place-items: center;
  height: 100vh;
  overflow: hidden;
}

.container {
  position: relative;
  display: grid;
  grid-template-rows: repeat(21, 4.77vh);
  grid-template-columns: repeat(21, 4.77vw);
  transform-style: preserve-3d;
  cursor: zoom-in;
  
  &:active {
    .monitor {
      transform: scale3d(3,3,3);
    }
  }
}

.monitor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  perspective: $perspective;
  transition: 300ms;
     transform: scale3d(2,2,2);
}

.trigger {
  position: relative;
  
  @for $i from 1 through 21 {
    @for $j from 1 through 21 {
      $key: ($i - 1) * 21 + $j;
      
      &:nth-child(#{$key}) {
        &:hover ~ .monitor {
          .camera {
            &.-x {
              transform: rotateX(($i - 11deg) * -$power / 2);
            }
            
            &.-y {
              transform: rotateY(($j - 11deg) * $power);
            }
          }
        }
      }
    }
  }
}

.camera {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  transition: 500ms;
  
  &.-x {
    transform: rotateX($defaultRotateX + 0deg);
  }
  
  &.-y {
    transform: rotateY($defaultRotateY + 0deg);
  }
  
  &.-z {
    transform: rotateY($defaultRotateZ + 0deg);
  }
}
// Template *** END
              
            
!

JS

              
                
              
            
!
999px

Console