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. 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

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

              
                
              
            
!

CSS

              
                body
  margin: 0
  background: #00baff
  overflow: hidden
              
            
!

JS

              
                !function () {
  function createCanvasElement (width, height, insertAfter) {
    // Creates a scaled-up canvas based on the device's
    // resolution, then displays it properly using styles
    function createHDCanvas (ratio) {
      var canvas = document.createElement('canvas');
      var ctx = canvas.getContext('2d');

      // Creates a dummy canvas to test device's pixel ratio
      ratio = (function () {
        var ctx = document.createElement('canvas').getContext('2d');
        var dpr = window.devicePixelRatio || 1;
        var bsr = ctx.webkitBackingStorePixelRatio ||
                  ctx.mozBackingStorePixelRatio ||
                  ctx.msBackingStorePixelRatio ||
                  ctx.oBackingStorePixelRatio ||
                  ctx.backingStorePixelRatio || 1;
        return dpr / bsr;
      })();

      canvas.width = width * ratio;
      canvas.height = height * ratio;
      canvas.style.width = width + 'px';
      canvas.style.height = height + 'px';
      ctx.setTransform(ratio, 0, 0, ratio, 0, 0);

      return canvas;
    }

    // Returns mouse coordinates that are
    // relative to the canvas, i.e. useful
    var relativeMouseCoords = function (event) {
      var totalOffsetX = 0;
      var totalOffsetY = 0;
      var currentElement = this;

      do {
        totalOffsetX += currentElement.offsetLeft - currentElement.scrollLeft;
        totalOffsetY += currentElement.offsetTop - currentElement.scrollTop;
        currentElement = currentElement.offsetParent;
      } while (currentElement);

      var canvasX = event.pageX - totalOffsetX;
      var canvasY = event.pageY - totalOffsetY;

      return {
        x: canvasX,
        y: canvasY
      };
    };

    var canvas = createHDCanvas();
    canvas.getCoords = relativeMouseCoords;

    if (insertAfter) insertAfter.parentNode.insertBefore(canvas, insertAfter.nextSibling);
    else document.body.appendChild(canvas);

    return canvas;
  };

  function handleKeydown (e) {
    e = e || window.event;
    if (!spacePressed && e.keyCode === 32) {
      spacePressed = true;
      ripple({
        x: windowWidth / 2,
        y: windowHeight / 2
      }, true);
    }
  }

  var ripple = (function() {
    var batch = [];

    function tick () {
      // increment radius step:
      batch.forEach(function (circle) { circle.radius += rippleSpeed; });

      // drawing step:
      ctx.fillStyle = '#00baff';
      ctx.fillRect(0, 0, windowWidth, windowHeight);

      batch.forEach(function (circle) {
        ctx.fillStyle = 'rgba(255,255,255,' + (1 - circle.radius / maxRadius) * 0.8 + ')';
        ctx.beginPath();
        ctx.arc(circle.x, circle.y, circle.radius, 0, Math.PI * 2);
        ctx.closePath();
        ctx.fill();
      });

      // remove finished animations step:
      batch = batch.filter(function (circle) {
        return circle.radius < maxRadius;
      });

      if (batch.length) {
        requestAnimationFrame(tick);
      }
    }

    return function (e, keyboard) {
      var circle;
      if (keyboard) circle = e;
      else {
        e = e || window.event;
        circle = canvas.getCoords(e);
      }
      circle.radius = 0;
      if (batch.push(circle) === 1) requestAnimationFrame(tick);
    };
  })();

  var windowHeight = window.innerHeight;
  var windowWidth = window.innerWidth;
  var maxRadius = Math.max(windowWidth, windowHeight);
  var rippleSpeed = maxRadius / 40;
  var canvas = createCanvasElement(windowWidth, windowHeight);
  var ctx = canvas.getContext('2d');
  var spacePressed = false;

  canvas.addEventListener('click', ripple, false);
  document.addEventListener('keydown', handleKeydown, false);
  document.addEventListener('keyup', function (e) {
    e = e || window.event;
    if (e.keyCode === 32) spacePressed = false;
  }, false);
}();

              
            
!
999px

Console