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

              
                <!-- 
mouseover text ( LTR is best )
Hopefully the pretty font loads on initial page load...seems to be a 1 in 5 shot that it doesn't && you're stuck with the ugly old regular font :( 
unless you reload the page.
!-->

<section>
 <p>Falling Down Is Part Of Life</p><hr><p class='two'>Getting Back Up Is Living</p>
</section>




















              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Elsie+Swash+Caps:900);

html, body{
  width:100%; 
  min-height:100%;
	margin:0;
  display:flex;
  justify-content:center;
  flex-direction:column;
  background:#EAE2CF;
  font-family: 'Elsie Swash Caps', cursive;
}
section{
  align-self:center;
  font-family: 'Elsie Swash Caps', cursive;
  font-weight:bold;
  text-align:center;
  & p.two{
    margin:-.5rem 0;
    padding:0;
  }
}
hr{
    height: 25px;
    border-style: solid;
    border-color: #E84D5B;
    border-width: 1px 0 0 0;
    border-radius: 20px;
    &:before { 
      display: block;
      content: "";
      height: 30px;
      margin-top: -31px;
      border-style: solid;
      border-color: #E84D5B;
      border-width: 0 0 1px 0;
      border-radius: 20px;
    }
}

              
            
!

JS

              
                (function(){
	var Part = function(x,y){
		this.x = x;
		this.y = y;
		this.bx = x;
		this.by = y;
		this.ax = 0;
		this.ay = 0;
		this.r;
		this.g;
		this.b;
		this.a;
	};
	Part.prototype = {
		r : function (v) { this.r = v;return this; },
		g : function (v) { this.g = v;return this; },
		b : function (v) { this.b = v;return this; },
		a : function (v) { this.a = v;return this; },
	};
	var String = function(str){
		this.fontSize = 40;
		this.font = 'Elsie Swash Caps';
		this.str = str;
		this.strWidth;
		this.d = document;
		this.c;
		this.$;
		this.parr = [];
		this.set();
	};
	String.prototype = {
		set : function(){
			var c = this.d.createElement('canvas');
			var $ = c.getContext('2d');
			$.strokeStyle = '#EAE2CF';
			$.textBaseline = 'top';
			$.font =  '45px Elsie Swash Caps';
			c.width = $.measureText(this.str).width;
			this.strWidth = c.width;
			c.height = ~~(45 * 1.2);
			$.strokeStyle = '#EAE2CF';
			$.textBaseline = 'top';
			$.font = '45px Elsie Swash Caps';
			$.fillText(this.str,0,0);
			this.c = c;
			this.$ = $;
		},
		app : function(e){
			e.appendChild(this.c);
			this.build();
			this.ev();
			return this;
		},
		el : function(){
			return this.c;
		},
		build : function(){
			var w = this.c.width,
				h = this.c.height,
				id =  this.$.getImageData(0,0,w,h).data,
				l = id.length
			;
			for(var i=0;i<l;i+=4){
				var y = ~~(i / (w*4));
				var x = (i/4)%w;
				var r = id[i];
				var g = id[i+1];
				var b = id[i+2];
				var a = id[i+3];
				if (r+g+b<100 && a>50){
					this.parr.push( (new Part(x,y)).r(r).g(g).b(b).a(a) );
				}
			}
		},
		ev : function(){
			var _this = this;
			this.c.onmouseover = function(){
				var __t = setInterval(_this.func(_this,_this.anim),50);
				setTimeout(function(){
					clearInterval(__t);
					var cnt = 10;
					var time = setInterval(function(){
						cnt--;
						for(var i=0,l=_this.parr.length;i<l;i++){
							var p=_this.parr[i];
							p.x = p.bx;
							p.y = p.by + ((_this.fontSize-p.by) * (cnt) / 10);
						}
						_this._draw(_this.parr);
						if (cnt<=0) {
							_this.$.clearRect(0,0,_this.c.width,_this.c.height);
							_this.def(_this.parr);
							_this._draw(_this.parr);
							clearInterval(time);
						}
					},30);
				},3000);
			};
		},
		func : function(thisFunc,func){
			return function(){
				func.call(thisFunc);
			};
		},
		anim : function(){
			this._move(this.parr);
			this._draw(this.parr);
		},
		_draw : function(parr){
				this.$.fillStyle = '#EAE2CF';
				this.$.fillRect(0,0,this.c.width,this.c.height);
			for(var i=0,l=parr.length;i<l;i++){
				var p=parr[i],x=~~p.x,y=~~p.y;
				this.$.fillStyle = '#E84D5B';
				this.$.fillRect(x,y,1,1);
			}
		},
		_move : function(parr){
			for(var i=0,l=parr.length;i<l;i++){
				var p=parr[i];
				p.ax == 0 ? p.ax = 0.2*(Math.random()-0.5) : p.ax *= 1.1;
				p.ay == 0 ? p.ay = (Math.random()) : p.ay *= 1.1;
				p.x += p.ax;
				p.y += p.ay;
			}
		},
		def : function(parr){
			for(var i=0,l=parr.length;i<l;i++){
				var p=parr[i];
				p.x = p.bx;
				p.y = p.by;
				p.ax = p.ay = 0;
			}
		}
	};
	
	setTimeout(function(){
		var loc = document.querySelectorAll('p,section');
		var start = (new Date().getTime())/1000;
		Array.prototype.map.call(loc,function(e){
			if ((new Date().getTime())/1000 > start+5) return;
			var nodes = Array.prototype.slice.call(e.childNodes);
			nodes.map(function(n){
				if ((new Date().getTime())/1000 > start+5) return;
				if (n instanceof Text){
					var id = n.textContent || n.id;
					var frag = document.createDocumentFragment();
					id.split('').map(function(str){
						if(str==='' || str==='\n' || str==='\r' || str==='\t')return;
						(new String(str)).app(frag).el().style.verticalAlign = 'top';
					});
					e.replaceChild( frag , n );
				}
			});
			
		});
	},0);

})();
              
            
!
999px

Console