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 cube
  .cube
    .face.x
    .face.y
    .face.z
    
.view
  .plane.main
    +cube  
            
          
!
            
              $side: 150px
$duration: 4s
$scale: 3

$stops: (#1DB4F7 0%, #24D8FE 20%, #1BAD58 40%, #79DE4F 60%, #FFFFFF 80%, #1DB4F7 100%)

@mixin frames($frames)
  @each $frame in $frames
    #{nth($frame, 2)}
      background: nth($frame, 1)


@mixin plane($w, $h)
  width: $w
  height: $h
  transform-style: preserve-3d
  
@mixin cube($side)
  transform-style: preserve-3d
  font-size: $side
  width: 1em
  height: 1em

  .face
    position: absolute
    box-sizing: border-box
    transform-style: preserve-3d
    width: 100%
    height: 100%
    
    &::after,
    &::before
      content: ''
      display: block
      position: absolute
      width: 100%
      height: 100%

    &::before
      transform: translateZ(-$side/2)

    &::after
      transform: translateZ($side/2)

    &.x
      transform: rotateX(90deg)
    &.y
      transform: rotateY(90deg) rotateZ(90deg)
  
@mixin view($p)
  position: absolute
  top: 0
  left: 0
  right: 0
  bottom: 0
  perspective: $p

@mixin center
  position: absolute
  top: 0
  left: 0
  right: 0
  bottom: 0
  margin: auto      

html, body
  font-size: $side
  background: #222
  overflow: hidden
  width: 100%
  height: 100%
  
.view
  @include view(400)
  pointer-events: none
  user-select: none
    
.plane
  @include plane($side, $side)
    
  &.main
    @include center
    transform: rotateX(60deg) rotateZ(150deg)
    animation: rotate 10s infinite linear    


.cube
  position: absolute
  @include cube($side)
    
  .x, .y
    &::before, &::after
      background: linear-gradient($stops)
      background-size: 1em ($scale + em)
      animation: sides $duration infinite linear
    
  .z
    &::before, &::after
      animation: top $duration infinite linear
    &::before
      animation-delay: -($duration * ($scale - 1 / $scale))
    

@keyframes rotate
  from
    transform: rotateX(60deg) rotateZ(0deg) 
  to
    transform: rotateX(60deg) rotateZ(360deg)         
    
@keyframes top
  @include frames($stops)
        

@keyframes sides
  0%
    background-position: 0 1em
  100%
    background-position: 0 ((1 - $scale) + em)
            
          
!
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