Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                h1 click for hot 8bit DOM action
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Press+Start+2P);

$white: #e4f9fa;
$yellow: #fde655;
$orange: #d47946;
$red: #7a2c1f;

body, html {
  font-family: 'Press Start 2P', cursive;
  -webkit-font-smoothing: none;
  background: #212121;
  color: $white;
  overflow: hidden;
  text-align: center;
  user-select: none;
  cursor: crosshair;
}
h1 {
  font-size: 1.75rem;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-weight: 200;
  text-transform: uppercase;
  line-height: 1.4;
  text-shadow: 0 0.25em 0 rgba(#000,.5);
}
.container {
  position: absolute;
  width: 20rem; height: 20rem;
  transform: translate(-50%,-50%);
  pointer-events: none;
  &:before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    display: block; 
    width: 2rem; height: 2rem;
    background: rgba(#000,.25);
    transform: rotate(45deg);
    outline: 10px solid rgba(#000,.1);
  }
  &:nth-child(4n),
  &:nth-child(7n){
    &:before {
      display: none;
    }
  }
}
.particle {
  position: absolute;
  display: block;
  top: 50%; left: 50%;
  width: 0; height: 0;
  
  @for $i from 0 through 20 {
    &:nth-child(#{$i + 1}) {
      .sparcle {
        animation-delay: $i * 50ms;
      }
    }
  } 
}
.sparcle {
  position: absolute;
  display: block;
  top: 0; left: 0;
  width: 3rem; height: 3rem;
  background: rgba($white,0);
  will-change: transform, box-shadow, background-color;
  transform: rotate(45deg) scale(0.5) translateZ(0);
  animation: explode 333ms;
  
  box-shadow: 0 0 0 0 $yellow;
}

@keyframes explode {
  0% {
    background-color: $white;
    transform: rotate(45deg) scale(1.2) translateZ(0);
    box-shadow: 0 0 0 0 $yellow;
  }
  40% {
    background-color: rgba($white,.1);
  }
  50% {
    transform: rotate(45deg) scale(1) translateZ(0);
    box-shadow: 0 0 0 10px $yellow;
    background-color: rgba($white,0);
  }
  60% {
    box-shadow: 0 0 0 50px $orange;
    transform: rotate(45deg) scale(0.5) translateZ(0);
  }
  70% {
    background-color: rgba($white,0);
    box-shadow: 0 0 0 30px $red;
  }
  100% {
    background-color: $red;
    box-shadow: 0 0 0 0 $red;
    transform: rotate(45deg) scale(0.25) translateZ(0);
  }
}
              
            
!

JS

              
                var mp3explosion = 'data:audio/mp3;base64, SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU2LjIzLjEwNgAAAAAAAAAAAAAA//tQwAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAAVAAAR9AAXFxcXIiIiIiIuLi4uLjo6Ojo6RUVFRVFRUVFRXV1dXV1oaGhoaHR0dHR/f39/f4uLi4uLl5eXl5eioqKirq6urq66urq6usXFxcXF0dHR0d3d3d3d6Ojo6Oj09PT09P////8AAAAATGF2YzU2LjI2AAAAAAAAAAAAAAAAJAAAAAAAAAAAEfQPir+jAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/7UMQAAAesTXWUEQAB0Cax9xJgAIAmSBEChCsoAVlAAAMBzvQhPk6nABAIZRxQEHVAgc+CAIflAfD+CYP/EDuJz8EDn+JwfxACAIA+H/7v5cMX3/atyaNuaJIpopBEkkT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qqqqqqqqqqqqqqqqqqqqqqqqqqv/7UsRqg8AAAaQAAAAgAAA0gAAABKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq';

var prefixes = ["webkit", "moz", "ms", ""];
function prefixedEvent(element, type, callback) {
	for (var p = 0; p < prefixes.length; p++) {
		if (!prefixes[p]) type = type.toLowerCase();
		element.addEventListener(prefixes[p]+type, callback, false);
	}
}

function transform ($e, x, y, scale, rotation, percent) {
  x = x || 0; y = y || 0; scale = scale || 1;
  unit = percent ? '%' : 'px';
  rotation = rotation || 0;
  
  transfromString = 'translate('+ x + unit + ', '+ y + unit + ') ' 
  								+ 'scale(' + scale + ') '
  								+ 'rotate(' + rotation + 'deg)';
  
  $e.style.webkitTransform = transfromString;
  $e.style.MozTransform = transfromString;
  $e.style.transform = transfromString;
}

function createParticle(x, y, scale) {
  var $particle = document.createElement('i');
 	var $sparcle = document.createElement('i');
  
  $particle.className = 'particle';
  $sparcle.className = 'sparcle';
  
  transform($particle, x, y, scale);
  $particle.appendChild( $sparcle );
  
  return $particle;
}

function explode ($container) {
  var particles = [];
  
  particles.push( createParticle(0,0,1) );
  particles.push( createParticle(50,-15,0.4) );
  particles.push( createParticle(50,-105,0.2) );
  particles.push( createParticle(-10,-60,0.8) );
  particles.push( createParticle(-10,60,0.4) );
  particles.push( createParticle(-50,-60,0.2) );
  particles.push( createParticle(-50,-15,0.75) );
  particles.push( createParticle(-100,-15,0.4) );
  particles.push( createParticle(-100,-15,0.2) );
  particles.push( createParticle(-100,-115,0.2) );
  particles.push( createParticle(80,-15,0.1) );

	particles.forEach(function(particle){
    $container.appendChild( particle );
    prefixedEvent(particle, "AnimationEnd", function(){
      var self = this;
      setTimeout(function(){
        requestAnimationFrame(function(){
          $container.removeChild(self);
        });
     	},100);
    });
  });
  
}

function exolpodeGroup (x, y, trans) {
  var $container = document.createElement('div');
  
  $container.className = 'container';
  $container.style.top = y + 'px';
  $container.style.left = x + 'px';
  
  transform( $container, trans.x, trans.y, trans.scale, trans.r, true );
  
  explode( $container );
	return $container;
}

function sparcle(event) {
  var explosions = [];
  
  explosions.push( exolpodeGroup(event.pageX, event.pageY, {scale: 1, x: -50, y: -50, r: 0}) );
  explosions.push( exolpodeGroup(event.pageX, event.pageY, {scale: .5, x: -30, y: -50, r: 180}) );
  explosions.push( exolpodeGroup(event.pageX, event.pageY, {scale: .5, x: -50, y: -20, r: -90}) );
  
	var audio = new Audio();
	audio.src = mp3explosion;
  
  requestAnimationFrame(function(){
    audio.play();
    explosions.forEach(function(boum, i){
      setTimeout(function(){
  			document.body.appendChild( boum );
      }, i * 100);
    });
  });
}

var interactionEvent = 'click';
if ('ontouchstart' in document.documentElement) {
  interactionEvent = 'touchstart';
}

document.addEventListener(interactionEvent, sparcle);
              
            
!
999px

Console