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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <div class="container">
  <div class="cube-container">
    <div class="cube cube1">
      <div class="box box1 front">Front</div>
      <div class="box box1 right">Right</div>
      <div class="box box1 top">Top</div>
      <div class="box box1 bottom">Bottom</div>
      <div class="box box1 left">Left</div>
      <div class="box box1 back">Back</div>

    </div>
    <div class="cube cube2">
      <div class="box box2 front">Front</div>
      <div class="box box2 back">Back</div>
      <div class="box box2 top">Top</div>
      <div class="box box2 bottom">Bottom</div>
      <div class="box box2 left">Left</div>
      <div class="box box2 right">Right</div>
    </div>
  </div>
</div>
            
          
!
            
              $width: 150px;
$height: 150px;

//colors for cube that is spinning horizontally
$color-Hfront: #40b9dc;
$color-Hback: #3dbadf;
$color-Htop: #5acaec;
$color-Hbottom: #82daf4;
$color-Hleft: #a3e5f9;
$color-Hright: #67d6f7;

//colors for cube that is spinning vertically
$color-Vfront: #8c31a5;
$color-Vback: #8e43a3;
$color-Vtop: #ab69bd;
$color-Vbottom: #d69de5;
$color-Vleft: #c060da;
$color-Vright: #c976e0;


@mixin flex {
  display: flex;
  justify-content: center;
  align-items: center;
  @content;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.container {
  @include flex;
  min-height: 100vh;

  .cube-container {
    perspective: 800px;
    @include flex {
      flex-direction: column;
    }

    .cube {
      transition: transform 2s ease-in;
      transform-style: preserve-3d;
      width: $width;
      height: $height;
      margin: 50px 0;

      &.cube1 {
        animation: horizontal-spin 5s infinite linear;
      }

      &.cube2 {
        animation: vertical-spin 5s infinite linear;
      }

      .box {
        width: 100%;
        height: 100%;
        position: absolute;
        color: white;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        font-family: 'Roboto', sans-serif;
        font-size: 20px;
        font-weight: 500;
        @include flex;

        &.front {
          background: $color-Hfront;
          transform: translateZ(($width/2));
        }
        
        &.box2 {
          &.front {
            background: $color-Vfront;
          }
        }

        &.back {
          background: $color-Hback;
          transform: translateZ(-($width/2)) rotateY(180deg);
        }

        &.box2 {
          &.back {
            background: $color-Vback;
            transform: translateZ(-($width/2)) rotateX(-180deg);
          }
        }

        &.top {
          background: $color-Htop;
          transform: rotateX(-90deg) translateY(-($width/2));
          transform-origin: top center;
        }

        &.box2 {
          &.top {
            background: $color-Vtop;
            transform: rotateX(90deg) translateY(-($width/2));
          }
        }

        &.bottom {
          background: $color-Hbottom;
          transform: rotateX(90deg) translateY(($width/2));
          transform-origin: bottom center;
        }

        &.box2 {
          &.bottom {
            background: $color-Vbottom;
            transform: rotateX(-90deg) translateY(($width/2));
          }
        }

        &.left {
          background: $color-Hleft;
          transform: rotateY(270deg) translateX(-($width/2));
          transform-origin: center left;
        }
        &.box2 {
          &.left {
            background: $color-Vleft;
          }
        }
        &.right {
          background: $color-Hright;
          transform: rotateY(-270deg) translateX(($width/2));
          transform-origin: top right;
        }
        &.box2 {
          &.right {
            background: $color-Vright;
          }
        }
      }
    }
  }
}

@keyframes horizontal-spin {
  from {
    transform: rotateY(0);
  }
  to {
    transform: rotateY(360deg);
  }
}

@keyframes vertical-spin {
  from {
    transform: rotateX(0);
  }
  to {
    transform: rotateX(360deg);
  }
}

            
          
!
999px
Loading ..................

Console