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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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">
	<h1>Click one of the links for a surprise</h1>

	<p>Lorem <a href="#">ipsum</a> dolor sit amet, consectetur adipisicing elit. Quasi nulla iusto voluptate culpa aliquid nam qui nemo quibusdam <a href="#">quas et</a>, inventore molestiae, debitis in vitae esse excepturi officiis beatae voluptas!</p>
	<p>Officiis placeat excepturi perspiciatis ullam culpa repudiandae omnis veniam quo, assumenda ipsa porro commodi fugiat doloremque officia mollitia ipsam sequi quaerat neque necessitatibus obcaecati ad, et, pariatur. Sed dignissimos, <a href="#">placeat</a>.</p>
	font-family 'Helvetica Neue', Helvetica, sans-serif
	margin 4em 0
	-webkit-font-smoothing antialiased

	width 70%
	margin 0 auto

	line-height 1.5

	color blue
	font-weight bold
	font-weight 500
              var anchors = document.querySelectorAll('a')

Array.prototype.forEach.call(anchors, function(anchor) {
	anchor.addEventListener('click', explode)

function explode(e) {
	var x = e.clientX
	var y = e.clientY
	var c = document.createElement('canvas')
	var ctx = c.getContext('2d')
	var ratio = window.devicePixelRatio
	var particles = []
	c.style.position = 'absolute'
	c.style.left = (x - 100) + 'px'
	c.style.top = (y - 100) + 'px'
	c.style.pointerEvents = 'none'
	c.style.width = 200 + 'px'
	c.style.height = 200 + 'px'
	c.width = 200 * ratio
	c.height = 200 * ratio
	function Particle() {
		return {
			x: c.width / 2,
			y: c.height / 2,
			radius: r(20,30),
			color: 'rgb(' + [r(0,255), r(0,255), r(0,255)].join(',') + ')',
			rotation: r(0,360, true),
			speed: r(8,12),
			friction: 0.9,
			opacity: r(0,0.5, true),
			yVel: 0,
			gravity: 0.1
	for(var i=0; ++i<25;) {
	function render() {
		ctx.clearRect(0, 0, c.width, c.height)
		particles.forEach(function(p, i) {
			angleTools.moveOnAngle(p, p.speed)
			p.opacity -= 0.01
			p.speed *= p.friction
			p.radius *= p.friction
			p.yVel += p.gravity
			p.y += p.yVel
			if(p.opacity < 0) return
			if(p.radius < 0) return
			ctx.globalAlpha = p.opacity
			ctx.fillStyle = p.color
			ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, false)
	;(function renderLoop(){
	setTimeout(function() {
	}, 3000)

var angleTools={getAngle:function(t,n){var a=n.x-t.x,e=n.y-t.y;return Math.atan2(e,a)/Math.PI*180},getDistance:function(t,n){var a=t.x-n.x,e=t.y-n.y;return Math.sqrt(a*a+e*e)},moveOnAngle:function(t,n){var a=this.getOneFrameDistance(t,n);t.x+=a.x,t.y+=a.y},getOneFrameDistance:function(t,n){return{x:n*Math.cos(t.rotation*Math.PI/180),y:n*Math.sin(t.rotation*Math.PI/180)}}};
function r(a,b,c){ return parseFloat((Math.random()*((a?a:1)-(b?b:0))+(b?b:0)).toFixed(c?c:0)); }

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................