cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              %button Restart
%ul.explanation
 %li 
  %span> side 1:
  transform: translate forward half cube width
 %li 
  %span>side 2: 
  transform: rotateY 180deg, translate half width
 %li
  %span> side 3: 
  transform: rotateY 90deg, translate half width
 %li
  %span> side 4:
  transform: rotateY -90deg, translate half width
 %li 
  %span> side 5:
  transform: rotateX 90deg, translate half width
 %li
  %span> side 6 
  transform: rotateX -90deg, translate half width  
  
.cube 
 -(1..6).each do |i|
  %div{:class => "face#{i}"}
  


            
          
!
            
              $transZ: translateZ(8rem);
$duration: 2s;
$fill-mode: forwards;
$timing-function: cubic-bezier(0,.6,1,.6);
$face-size: 16rem;

html, body { height: 100%; }

body {
  perspective: 800px;
}

button {
  margin: 5px;
  padding: 5px 10px;
  font-size: 1.3rem;
  cursor: pointer;
}

.explanation {
  display: block;
  margin-top: 10px;
  position: relative;
  text-align: center;
  
  li {
    opacity: 0;
    margin-bottom: 10px;
  }
  
  span {
    margin-right: 10px;
    font-weight: bold;
  }
}

.cube {
  &, * {
    box-sizing: border-box;
    position: absolute;
    top: 50%; 
    left: 50%;
  }
  transform-style: preserve-3d;
  animation: initialRotation 1s $fill-mode $timing-function, 
             spinCube 20s 19s 1 $fill-mode linear;
}

[class^="face"] {
  width: $face-size;
  height: $face-size;
  margin: -$face-size / 2;
  background-color: red;
  opacity: 0.2;
  outline: 1px solid rgba(black, 0.5);
  font-size: 3rem;
  line-height: $face-size;
  text-align: center;
}

@for $i from 1 through 6{
  $delay: $i*3s;
  .face#{$i} {
    animation: formFace#{$i} $duration $delay $fill-mode $timing-function; 
    
    &:before {
      content: "SIDE #{$i}";
      opacity: 0;
      animation: displayText $duration $delay $fill-mode;
    }
  }
  
  .explanation li:nth-child(#{$i}) {
    animation: displayExplanation 7s $delay;
  }
} 

@keyframes initialRotation {
  100% { transform: rotateX(-35deg) rotateY(35deg); }
}

@keyframes displayText {
  100% { opacity: 1; }
}

@keyframes displayExplanation {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

@keyframes spinCube {
  0% { transform: rotateX(-35deg) rotateY(35deg); }
  15%, 20% { transform: rotateX(0) rotateY(0); }
  30%, 35% { transform: rotatey(-180deg);}
  45%, 50% { transform: rotateY(-90deg); }
  60%, 65% { transform: rotateY(90deg); }
  75%, 80% { transform: rotateX(-90deg); }
  90%, 95% { transform: rotateX(90deg);}
  100% { transform: rotateX(0) rotateY(0); }
}

@keyframes formFace1 {
  100% { transform: $transZ }
}

@keyframes formFace2 {
  50% { transform: rotateY(180deg); }
  100% { transform: rotateY(180deg) $transZ; }
}

@keyframes formFace3 {
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(90deg) $transZ; }
}

@keyframes formFace4 {
  50% { transform: rotateY(-90deg); }
  100% { transform: rotateY(-90deg) $transZ; }
}

@keyframes formFace5 {
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(90deg) $transZ; }
}

@keyframes formFace6 {
  50% { transform: rotateX(-90deg); }
  100% { transform: rotateX(-90deg) $transZ; }
}


            
          
!
            
              $("button").on("click", function(){	
 $(".cube, .explanation").appendTo("body");
});
            
          
!
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.
Loading ..................

Console