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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                .controls
  form(action="")
    legend Controls
    form-group
      label(for="") Rotation speed
      .form-control
        input#rotationSpeedInput(type="range" min="1" max="120" step="1" value="30")
.wrap
  .cube.animation_name_spinRight.animation_duration_30.animation_iteration-count_infinite.animation_timing-function_linear#cube-1
    .front 
    .back 
    .top 
    .bottom 
    .left 
    .right 
.wrap.wrap_size_s
  .cube.cube_size_s.animation_name_spinRight.animation_duration_10.animation_iteration-count_infinite.animation_timing-function_linear#cube-2
    .front
    .back
    .top
    .bottom
    .left
    .right
              
            
!

CSS

              
                :root {
  --rotation-speed: 30s;
}

body
  display flex
  min-height 70vh
  align-items center
  justify-content space-between
  background radial-gradient(darkgray, dimgray)
  font 24px / 1.5 sans-serif

.controls
  position fixed
  z-index 10
  display block
  background linear-gradient(silver, silver)
  left 0
  right 0
  bottom 0
  padding 1rem
  & legend
    font-weight bold
    font-size 0.8rem
    text-transform uppercase
  
.wrap
  perspective 380px
  perspective-origin 50% 100px
  margin auto

.wrap_size_s
  perspective 1000px
  perspective-origin 50% 120px
  
.cube
  position relative
  width 200px
  transform-style preserve-3d
  transition all .5s ease
  & div
    width 200px
    height 200px
    position absolute
    transition all .3s ease
    opacity 1
    display flex
    align-items center
    justify-content center
    color #fff
    font 2.5rem / 1.5 sans-serif
    text-transform uppercase
    letter-spacing 5px
    padding 1rem
    box-sizing border-box
    border 5px solid darkred
    background radial-gradient(darkred 10%, transparent 10%, transparent 20%, maroon 20%, crimson 50%, darkred) !important
    box-shadow 0 0 30px rgba(255, 0, 0, .2)

.cube_size_s
  width 100px
  & > div
    width 100px
    height 100px
  & .front
    transform translateZ(0px) translateY(0)
  & .back
    transform translateZ(-100px) rotateY(180deg)
  & .top
    transform rotateX(-90deg) translateY(0px)
  & .bottom
    transform rotateX(90deg) translateY(0px)
  & .left
    transform rotateY(270deg) translateX(-100px)
  & .right
    transform rotateY(-270deg) translateX(100px)
    
.front
  background pink
  transform translateZ(100px) translateY(0)
  transform-origin right
  
.back
  background crimson
  transform translateZ(-100px) rotateY(180deg)

.top
  background lightblue
  transform rotateX(-90deg) translateY(-100px)
  transform-origin top center
  
.bottom
  background gold
  transform rotateX(90deg) translateY(100px)
  transform-origin bottom center
  
.left
  background midnightblue
  transform rotateY(270deg) translateX(-100px)
  transform-origin center left
  
.right
  background chocolate
  transform rotateY(-270deg) translateX(100px)
  transform-origin top right
  
.cube:hover .back
  transform translateZ(-130px) rotateY(180deg)
.cube:hover .front
  transform translateZ(130px) translateY(0)
.cube:hover .top
  transform rotateX(-90deg) translateZ(-30px) translateY(0px)
.cube:hover .bottom
  transform rotateX(90deg) translateY(0) translateZ(-30px)
.cube:hover .left
  transform rotateY(270deg) translateX(-200px)
.cube:hover .right
  transform rotateY(-270deg) translateX(200px)
  
.toggleBack
  transform translateZ(-100px) rotate(180deg) translateY(200px)
  
.openFront
  transform translateZ(100px) rotateY(90deg)

.animation_name_spinRight
  animation-name spinRight

.animation_duration_10
  animation-duration 10s
  
.animation_duration_30
  animation-duration var(--rotation-speed)

.animation_iteration-count_infinite
  animation-iteration-count infinite

.animation_timing-function_linear 
  animation-timing-function linear
  
@keyframes spinRight {
  from {
    transform rotateY(0deg)
  }
  to {
    transform rotateY(360deg)
  }
}

@keyframes spinLeft {
  from {
    transform rotateY(0deg)
  }
  to {
    transform rotateY(-360deg)
  }
}
              
            
!

JS

              
                const cube = document.querySelector('.wrap')
const front = document.querySelector('.front')
const rotationSpeedInput = document.querySelector('#rotationSpeedInput')
const cube1 = document.querySelector('#cube-1')

function setRotationSpeed(speed) {
  let rotationSpeed = speed + 's'
  cube1.style.setProperty('--rotation-speed', rotationSpeed)
}

setRotationSpeed(10)

let cube1Style = getComputedStyle(cube1).getPropertyValue('--rotation-speed')
console.log(cube1Style)

rotationSpeedInput.addEventListener('input', (e) => {
  setRotationSpeed(e.target.value)
})
              
            
!
999px

Console