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

              
                
<html lang="en">
<head>
        <title>Oritro's Experiment Lab - Letterer.js</title>
        <meta charset="UTF-8" />
        
</head>
        <body>
                <div id='mainText'>
                        <h1>// What do you know about John Lennon? </h1>
                        <p>John Winston Ono Lennon, MBE was an English musician, singer and songwriter who rose to worldwide fame as a founder member of the Beatles, the most commercially successful and critically acclaimed band in the history of popular music</p>
                        <p>Born: October 9, 1940, Liverpool, United Kingdom</p>
                        <p>Died: December 8, 1980, New York City, New York, United States</p>
                        <p>#<a href="http://en.wikipedia.org/wiki/John_Lennon"> Reference </a></p>
                </div>
                <footer id="footer">
                  <p>Oritro's Experiment Lab // <a href="https://codepen.io/oritromax/pen/sIhva">Codepen</a> // <a href="http://ioritro.com">Homepage</a> // <a href="http://ioritro.com/lab">Lab Homepage</a></p>

                </footer>
	
                 
                
        </body>
</html>
              
            
!

CSS

              
                body{ font:20px/1.3 Georgia; }
                
                #mainText{ 
                	width:50%; 
                	min-width:500px; 
                	margin:50px auto; 
                    background: #D9534F;
                    padding: 10px;
                    border-radius: 3px;
                }

                #mainText h1 {
                	font: 30px/1.5 Georgia;
                }

                #mainText p{
                	text-align: justify;
                }

                #mainText a{
                	color: #fff;
                }
                
                word{ display:inline-block; }
                
                a letter{ color:inherit; }
                letter{ display:inline-block; white-space:pre; background:none; transition:.4s; }
                letter.initial{ opacity:0; text-shadow:0 0 9px; color:#FFF; -webkit-transform:scale(8); -webkit-transform-origin:150% 50%; transform:scale(8); transform-origin:150% 50%; }
                        
                
                #footer {
                  position:fixed;
                  left:0px;
                  bottom:0px;
                  height:60px;
                  color:#777;
                  width:100%;
                  background:#EEE;
                }

                #footer p {
                	padding-left: 10px;
                	padding-right: 10px;
                }

                #footer a {
                	color: #00b5ad;
                	text-decoration: none;
                	padding-left: 2px;
                	padding-right: 2px;
                	border-radius: 4px;
                }

                #footer a:hover {
                	text-shadow: 1px 1px 10px #ffb6b5;
                }

/* You know, Internet Explorer still live in this world  */
* html #footer {
   position:absolute;
   top:expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');
}
              
            
!

JS

              
                function letterer(element){
	if( !document.createTreeWalker ) return false;
	
	var letter, letterElm, parent, wordElm, letters, walker, node, 
		supportsTrim = String.prototype.trim;
		
	walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT, null, false);

	while( node = walker.nextNode() ){
	   if( node.nodeType == 3 ){  // trim() can be removed (not supported in IE)
			if( supportsTrim ? node.nodeValue.trim() : node.nodeValue ){
				letters = node.nodeValue.split('').reverse();
				wordElm = document.createElement('word');
				node.nodeValue = '';
				// do this for every letter in this text-node
				while( letter = letters.pop() ){
					parent = node.parentNode;
					
					letterElm = document.createElement('letter');
					letterElm.className = 'initial'; // add a class for transition purposes 
					letterElm.innerHTML = letter;
					
					// check for a space
					if( letter == ' ' ){
						parent.insertBefore( wordElm, node );
						wordElm = document.createElement('word');
						parent.insertBefore( letterElm, node );
					}
					else
						wordElm.insertBefore(letterElm, null);
				}
				parent.insertBefore( wordElm, node );
			}
		}
	}
}function letterer(element){
	if( !document.createTreeWalker ) return false;
	
	var letter, letterElm, parent, wordElm, letters, walker, node, 
		supportsTrim = String.prototype.trim;
		
	walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT, null, false);

	while( node = walker.nextNode() ){
	   if( node.nodeType == 3 ){  // trim() can be removed (not supported in IE)
			if( supportsTrim ? node.nodeValue.trim() : node.nodeValue ){
				letters = node.nodeValue.split('').reverse();
				wordElm = document.createElement('word');
				node.nodeValue = '';
				// do this for every letter in this text-node
				while( letter = letters.pop() ){
					parent = node.parentNode;
					
					letterElm = document.createElement('letter');
					letterElm.className = 'initial'; // add a class for transition purposes 
					letterElm.innerHTML = letter;
					
					// check for a space
					if( letter == ' ' ){
						parent.insertBefore( wordElm, node );
						wordElm = document.createElement('word');
						parent.insertBefore( letterElm, node );
					}
					else
						wordElm.insertBefore(letterElm, null);
				}
				parent.insertBefore( wordElm, node );
			}
		}
	}
}

var lettersContainer = document.getElementById('mainText'),
                                letters, 
                                delay = 0,
                                delayJump = 33,
                                totalLetters;
                        
                        // Break to letters
                        letterer( lettersContainer );
                        // get all "letter" elements
                        
        
                        letters = lettersContainer.getElementsByTagName('letter');
                        totalLetters = letters.length;
                        
                        for( var i=0; i < totalLetters; i++ ){
                                doTimer(letters[i], delay);
                                delay += delayJump;
                                // if the letter is a "space" then pause for a little more, to have some delay between words 
                                if( letters[i].innerHTML == ' ' )
                                        delay += delayJump * 3;
                        }
                        
                        function doTimer(letter, delay){
                                setTimeout(function(){ 
                                        letter.removeAttribute('class');
                                }, delay);
                        }

              
            
!
999px

Console