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

              
                h1 Happy Valentines Day!
p#clickHere Click me everywhere. 
canvas#c(width=500,height=500)
              
            
!

CSS

              
                body { 
  overflow: hidden; 
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  background-color: #eee;
  transition: background-color 1s ease-in-out;
}
#c {
  position: relative;
  z-index: 1;
  filter: contrast(3);
}
h1 {
  width: 100vw;
  height: 100vh;
  position: absolute;
  z-index: 2;
  color: #eee;
  transition: color 1s ease-in-out;
  font-size: 8em;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center; 
  cursor: pointer;
}
p#clickHere {
  text-transform: uppercase;
  padding: 1em;
}
              
            
!

JS

              
                var c 		 = document.getElementById('c');
var _ 		 = c.getContext('2d');
var h1 		 = document.querySelector('h1');
var RAD 	 = Math.PI / 180;
var speed  = 3;
var setCanvasSize = function () {
  c.width  = window.innerWidth;
  c.height = window.innerHeight;
};
var randHeart = function () {
		   return ["❤","♥"][Math.floor(Math.random() * 2)];
};
var Sprite = function (x, y, rot) {
  this.x    = x || Math.random() * c.width;
  this.y    = y || Math.random() * c.height;
  this.rot  = rot || 0;
  this.c    = 'rgba(238,85,85,1)';
  this.text = randHeart();
};
var items = [new Sprite];
var shape = function (x, y, text, c) {
  _.font="5em Arial";
  _.fillStyle = c;
  _.fillText(text, x, y);
};
var clear = function () {
  _.clearRect(0,0, c.width, c.height);
}
var listen = function () {
  window.onresize = function () {
    setCanvasSize();
  };
  window.onmousedown = function (e) {
    items.push(new Sprite(e.x, e.y));
  };
  var alpha = 0.1;
  h1.onclick = function (e) {
    document.querySelector('p').style.display = "none";
    h1.style.color = 'rgba(238,85,85,'+alpha+')';
    document.body.style.backgroundColor = 'rgba(238,85,85,'+alpha+')';
    if (alpha <= 0.3) {
      alpha += 0.02;
    } else {
      h1.style.color = 'rgb(247,164,164)';
    }
    return false;
  };
};
var setup = function () {
  setCanvasSize();
  listen();
}; setup();
var render = function () {
 	 clear();  
  for (var i = 0; i < items.length; i++) {
    var item = items[i];
    shape(item.x, item.y, item.text, item.c);
    item.x += Math.cos(Math.round(Math.random() * item.rot) / RAD) * speed;
    item.y += Math.sin(Math.round(Math.random() * item.rot) / RAD) * speed;
    item.rot +=  speed;
    if (item.y >= c.height || item.y <= 0) item.y = -item.y;
    if (item.x >= c.width || item.x <= 0) item.x = -item.x;
  }
};
window.requestAnimFrame = (function(){
  return window.requestAnimationFrame||window.webkitRequestAnimationFrame ||window.mozRequestAnimationFrame||function( callback ){
    window.setTimeout(callback, 1000 / 60);
	};
})();
(function animloop(){
  requestAnimFrame(animloop);
  render();
})();
              
            
!
999px

Console