Pen Settings

HTML

CSS

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

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

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.

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 cube
  .cube
    .face.x
    .face.y
    .face.z
    
mixin sponge
  .sponge
    - for (var x = 0; x < 20; x++)
      if block
        block
      else
        +cube

input#show(type='checkbox')
label.show(for='show') Show pen
.view
  .plane.main
    +sponge
      +sponge
              
            
!

CSS

              
                $side: 150px
$topColor: white
$rightColor: darken($topColor, 20%)
$leftColor: darken($topColor, 40%)

@mixin plane
  width: 1em
  height: 1em
  transform-style: preserve-3d

@mixin fast-cube
  @include plane

  .face
    
    &, &::after
      position: absolute
      transform-style: preserve-3d
      width: 100%
      height: 100%
      //backface-visibility: hidden

    &::after
      display: block
      content: ''
      transform: rotateY(180deg) translateZ(1em)

    &.x
      transform: rotateX(90deg) translateZ(0.5em)
    &.y
      transform: rotateY(90deg) translateZ(0.5em)
    &.z
      transform: translateZ(0.5em)
  
@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
  background: #222
  overflow: hidden
  width: 100%
  height: 100%
  
.view
  @include view(400)
  display: none
  pointer-events: none
  user-select: none
    
.plane
  @include plane
    
  &.main
    @include center
    transform: rotateX(60deg) rotateZ(150deg)
    //animation: rotate 10s infinite linear    


.cube
  position: absolute
  @include fast-cube
    
  .face
    //box-sizing: border-box
    //border: $side / 3 solid black

  .z, .z::after
    background: $topColor
  .y, .y::after
    background: $leftColor
  .x, .x::after
    background: $rightColor
    
  
.sponge
  font-size: $side
  height: 1em
  width: 1em
  transform-style: preserve-3d
  position: absolute

  
  > *
    font-size: (1 / 3) + em
  
  @for $i from 1 through 20
    > :nth-child(#{$i})
      $x: 0
      $y: 0
      $z: 0
  
      @if 1 <= $i and $i <= 8
        $z: 1
      @else if 13 <= $i and $i <= 20
        $z: -1
        
      @if index((1, 2, 3, 9, 10, 13, 14, 15), $i)
        $x: -1
      @else if index((4, 5, 6, 11, 12, 16, 17, 18), $i)
        $x: 1
        
      @if index((1, 4, 7, 9, 11, 13, 16, 19), $i)
        $y: -1
      @else if index((3, 6, 8, 10, 12, 15, 18, 20), $i)
        $y: 1
 
      transform: translate3d($x + em, $y + em, $z + em)

      
#show
  display: none
  &:checked
    ~ .show
      display: none
    ~ .view
      display: block
  
.show
  font-size: 1.5rem
  font-family: sans-serif
  color: white
  text-transform: uppercase
  cursor: pointer
  border: 2px solid white
  padding: 1rem 1.5rem
  display: block
  position: absolute
  top: 50%
  left: 50%
  transform: translate3d(-50%, -50%, 0)
  
      
@keyframes rotate
  from
    transform: rotateX(60deg) rotateZ(0deg) 
  to
    transform: rotateX(60deg) rotateZ(360deg) 
              
            
!

JS

              
                
              
            
!
999px

Console