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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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.

            
              .pen
  .container
    - (1..8).each do |i|
      - (1..8).each do |j|
        %div(class="piece-#{i}-#{j} piece")
          .one
            .two
  %h2 Pure CSS
            
          
!
            
              @import "compass/css3";

$totalPiecesPerRow: 8;
$totalPiecesPerColumn: $totalPiecesPerRow;

$posTotalPieces: $totalPiecesPerRow / 2;

$penHeight: 400px;
$penWidth: $penHeight;

$pieceWidth: $penHeight / $totalPiecesPerRow;
$pieceHeight: $penWidth / $totalPiecesPerColumn;

$pieceBgColor: darken(dodgerblue, 10%);
$pieceBgColor: darken(dodgerblue, 20%);
$pieceBgColor: #587498;
$pieceBgColor: dodgerblue;

.pen{
  position: absolute;
  width: $penWidth;
  height: $penHeight;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  //background: orangered;
  //background: radial-gradient(ellipse at center, #f7f711 0%,#a80321 82%,#a80321 100%);
  background: radial-gradient(ellipse at center, #f7f711 0%,#b24c03 100%);
  //background: ;
}

.container{
  position: absolute;
  width: $penWidth;
  height: $penHeight;
  perspective: 600px;
}

.piece{
  //border: 1px solid red;
  position: absolute;
  width: $pieceWidth;
  height: $pieceHeight;
  perspective: 600px;
  perspective-origin: center center;
  .one{
    position: absolute;
    width: 100%;
    height: 100%;
    background: $pieceBgColor;
  }
  @for $i from 1 through $totalPiecesPerRow{
    @for $j from 1 through $totalPiecesPerColumn{
      &.piece-#{$i}-#{$j}{
        left: ($i - 1) * $pieceHeight;
        top: ($j - 1) * $pieceWidth;
      }
    }
  }
}

@function coordX($x){
  $rx: $totalPiecesPerRow/2 + $x;
  @if ($x < 0) {
    $rx: $rx + 1;
  }
  @return $rx;
}
@function coordY($y){
  $ry: $totalPiecesPerRow/2 - $y;
  @if ($y > 0) {
    $ry: $ry + 1;
  }
  @return $ry;
}

$maxDist: sqrt($posTotalPieces*$posTotalPieces + $posTotalPieces*$posTotalPieces);
$d: 0;
@for $i from 1 through $posTotalPieces{
  @for $j from 1 through $i{
    $d: $d + 1; //just an index
    $x: coordX($i);
    $y: coordY($j);
    $mx: coordX(-$i);
    $my: coordY(-$j);
    $dist: sqrt($i*$i + $j*$j);
    $angle: round(atan($j / $i) * (180/pi())) * 1deg;
    @keyframes circ-#{$d}-m {
      $startPercent: 70 * $dist/$maxDist;
      0%{
        //background-color: $pieceBgColor;
        transform: translateZ(0px) rotateY( 0deg ) rotateX(0deg) rotateZ(-$angle);
        box-shadow: inset 0px 0px 20px 2px transparent;
      }
    #{$startPercent}%{
    //background-color: $pieceBgColor;
    //box-shadow: none;
    transform: translateZ(0px) rotateY( 0deg ) rotateX(0deg) rotateZ(-$angle);
    background-color: $pieceBgColor;
    box-shadow: inset 0px 0px 20px 2px transparent;
  }
    #{$startPercent + 15}%{
      //background-color: transparent;
      //box-shadow: inset 0px 0px 14px 3px red;
    transform: translateZ(40px) rotateY( 85deg ) rotateX(0deg) rotateZ(-$angle) scale(0.8);
    background-color: darken($pieceBgColor, 10%);
    box-shadow: inset 0px 0px 20px 2px #b24c03;

  }
  #{$startPercent + 40}%{
    //background-color: $pieceBgColor;
    //box-shadow: none;
  transform: translateZ(0px) rotateY( 0deg ) rotateX(0deg) rotateZ(-$angle);
  background-color: $pieceBgColor;
  box-shadow: inset 0px 0px 20px 2px transparent;
  }
  100%{
    //background-color: $pieceBgColor;
  transform: translateZ(0px) rotateY( 0deg ) rotateX(0deg) rotateZ(-$angle);
  box-shadow: inset 0px 0px 20px 2px transparent;
  }
  }
    @keyframes circ-#{$d} {
      $startPercent: 70 * $dist/$maxDist;
      0%{
        //background-color: $pieceBgColor;
        transform: translateZ(0px) rotateY( 0deg ) rotateX(0deg) rotateZ($angle);
  box-shadow: inset 0px 0px 3px 0px transparent;
      }
      #{$startPercent}%{
        //background-color: $pieceBgColor;
        //box-shadow: none;
        transform: translateZ(0px) rotateY( 0deg ) rotateX(0deg) rotateZ($angle);
        background-color: $pieceBgColor;
  box-shadow: inset 0px 0px 3px 0px transparent;
      }
      #{$startPercent + 15}%{
        //background-color: transparent;
        //box-shadow: inset 0px 0px 14px 3px red;
        transform: translateZ(40px) rotateY( 85deg ) rotateX(0deg) rotateZ($angle) scale(0.8);
        background-color: darken($pieceBgColor, 10%);
  box-shadow: inset 0px 0px 20px 2px #b24c03;
      }
      #{$startPercent + 40}%{
        //background-color: $pieceBgColor;
        //box-shadow: none;
        transform: translateZ(0px) rotateY( 0deg ) rotateX(0deg) rotateZ($angle);
        background-color: $pieceBgColor;
  box-shadow: inset 0px 0px 3px 0px transparent;
      }
      100%{
        //background-color: $pieceBgColor;
        transform: translateZ(0px) rotateY( 0deg ) rotateX(0deg) rotateZ($angle);
  box-shadow: inset 0px 0px 3px 0px transparent;
      }
    }
    .piece-#{$x}-#{$y}{
      transform: rotate(-$angle );
      .one{
        transform: rotateZ($angle);
        animation: circ-#{$d} 5s linear infinite;

      }
    }
    .piece.piece-#{$x}-#{$my}{
      $a: -$angle;
      transform: rotateZ(-$a);
      .one{
        transform: rotateZ($a);
        animation: circ-#{$d}-m 5s linear infinite;
      }
    }
    .piece.piece-#{$mx}-#{$y}{
      $a: 180deg - $angle;
      transform: rotateZ(-$a);
      .one{
        transform: rotateZ($a);
        animation: circ-#{$d}-m 5s linear infinite;
      }
    }
    .piece.piece-#{$mx}-#{$my}{
      $a: 180deg + $angle;
      transform: rotateZ(-$a);
      .one{
        transform: rotateZ($a);
        animation: circ-#{$d} 5s linear infinite;
      }
    }
    .piece.piece-#{$y}-#{$x}{
      $a: 90deg - $angle;
      transform: rotateZ(-$a);
      .one{
        transform: rotateZ($a);
        animation: circ-#{$d}-m 5s linear infinite;
      }
    }
    .piece.piece-#{$my}-#{$x}{
      $a: 90deg + $angle;
      transform: rotate(-$a);
      .one{
        transform: rotate($a);
        animation: circ-#{$d} 5s linear infinite;
      }
    }
    .piece.piece-#{$y}-#{$mx}{
      $a: 270deg + $angle;
      transform: rotate(-$a);
      .one{
        transform: rotate($a);
        animation: circ-#{$d} 5s linear infinite;
      }
    }
    .piece.piece-#{$my}-#{$mx}{
      $a: 270deg - $angle;
      transform: rotate(-$a);
      .one{
        transform: rotate($a);
        animation: circ-#{$d}-m 5s linear infinite;
      }
    }

    .piece.piece-#{$x}-#{$y},
    .piece.piece-#{$mx}-#{$y},
    .piece.piece-#{$x}-#{$my},
    .piece.piece-#{$mx}-#{$my},
    .piece.piece-#{$y}-#{$x},
    .piece.piece-#{$my}-#{$x},
    .piece.piece-#{$y}-#{$mx},
    .piece.piece-#{$my}-#{$mx},{
      //background-color: hsl( 50, 50%, $v );
      //animation: circ-#{$d} 5s linear infinite;

      .one{
        //transform: rotate($angle);
        //animation: circ-#{$d} 5s linear infinite;
      }
    }
  }
}

@keyframes smoke {
  0%{
    transform: translateX(0px) translateY(0px) scale(0.2);
    opacity: 0;
  }
  10%{
    transform: translateX(0px) translateY(-3px) scale(0.2);
    opacity: 1;
  }
  100%{
    transform: translateX(-10px) translateY(-60px) scale(1);
    opacity: 0;
  }
}

@keyframes smoke-r {
  0%{
    transform: translateX(0px) translateY(0px) scale(0.2);
    opacity: 0;
  }
  10%{
    transform: translateX(0px) translateY(-3px) scale(0.2);
    opacity: 1;
  }
  100%{
    transform: translateX(10px) translateY(-60px) scale(1);
    opacity: 0;
  }
}

$sw: $pieceWidth;
.smoke{
  position: absolute;
  width: $sw;
  height: $sw;
  top: 0%;
  left: 0%;

  margin-top: -$sw;

  margin-left: -$sw/2;

  transform-origin: 50% 100%;

  background: rgba(200, 200, 200, 0.5);
  filter: blur(10px);
  z-index: 100;

  border-radius: 50%;
  @for $i from 1 through 10{
    &.smoke-#{$i}{
      &.two{
        left: 100%;
      }
      &.three{
        left: 100%;
        top: 100%;
      }
      &.four{
        top: 100%;
      }
      animation: smoke 5s linear infinite;
      @if $i % 2 == 0{
        animation: smoke-r 5s linear infinite;
      }
      animation-delay: -#{$i/2}s;
    }
  }

}

html {
  box-sizing: border-box;
  //background: #F1ECDB;
  background: dodgerblue;
}
*, *:before, *:after {
  box-sizing: inherit;
}
h2{
  color: $pieceBgColor;
  text-align: center;
  font-size: 2.5em;
  //text-shadow: 0px 0px 3px #444;
  z-index: 300;
  position: absolute;
  padding: 0;
  margin: 0;
  right: 0;bottom: $pieceHeight;
}
            
          
!
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