123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div id='mainText'>
	<h1>Client-side scripting: <i>javascript</i></h1>
	<p><b>Client-side scripting</b> generally refers to the class of <a title="Computer program" href="/wiki/Computer_program">computer programs</a> on the <a title="World Wide Web" href="/wiki/World_Wide_Web">web</a> that are <a class="mw-redirect" title="Execution (computers)" href="/wiki/Execution_(computers)">executed</a> <i><a title="Client-side" href="/wiki/Client-side">client-side</a></i>, by the user's <a title="Web browser" href="/wiki/Web_browser">web browser</a>, instead of <i><a title="Server-side" href="/wiki/Server-side">server-side</a></i> (on the <a title="Web server" href="/wiki/Web_server">web server</a>). 
	<br>This type of <a title="Computer programming" href="/wiki/Computer_programming">computer programming</a> is an important part of the <a title="Dynamic HTML" href="/wiki/Dynamic_HTML">Dynamic HTML</a> (DHTML) concept, enabling <a title="Web page" href="/wiki/Web_page">web pages</a> to be <a class="mw-redirect" title="Script (computer programming)" href="/wiki/Script_(computer_programming)">scripted</a>; that is, to have different and changing content depending on user input, environmental conditions (such as the time of day), or other variables.</p>
</div>
<footer class='credit'>
	<span>A demo by <em>Yair Even-Or</em></span><br />
	<a href='https://github.com/yairEO/letterer' title='cool client-side stuff'>GITHUB PROJECT</a>
</footer>
            
          
!
            
              body{ font:20px/1.3 arial; background:#FFF; }

#mainText{ 
  width:50%; 
  min-width:550px; 
  margin:50px auto;
  display:none;
}

word{ display:inline-block; }

a letter{ color:inherit; } /* for links */
/* This is the NORMAL state of a character */
letter{ 
  display:inline-block; 
  white-space:pre; 
  background:none; 
  transition:.4s; 
}
/* Below is the INITIAL state of a character */
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%; 
}
	


/* NOT RELATED 
-------------------------*/
.credit{ position:absolute; bottom:10px; left:10px; padding:10px 20px; color:#777; font-size:11px; text-align:center; background:#EEE; border-radius:10px;  }
            
          
!
            
              // Breaks HTML into individual characters, and words,
// without messing up the semantic structure.

// This code uses LETTERER.JS
// https://github.com/yairEO/letterer
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 ){
			if( supportsTrim ? node.nodeValue.trim() : node.nodeValue ){
				letters = node.nodeValue.split('').reverse();
				wordElm = document.createElement('word');
				node.nodeValue = '';
				parent = node.parentNode;		
				// do this for every letter in this text-node
				while( letter = letters.pop() ){
					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.appendChild(letterElm);
				}
				parent.insertBefore( wordElm, node );
			}
		}
	}
}



// The code below initialize Letterer.js and then loops
// on every character and removes it's initial class,
// to trigger a transition effect.

var lettersWrap = document.getElementById('mainText'),
	letters, 
	delay = 0, // initial delay
	delayJump = 33, // adjust this
	totalLetters;

// Break to letters
letterer( lettersWrap );
lettersWrap.style.display = 'block';
// get all "letter" elements

letters = lettersWrap.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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console