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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 or require. We'll also process your JavaScript with Babel.

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

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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

            
              <h1 title='Sure this name is trademarked!'>Typo</h1>
<pre id="output"></pre>
<p>
  <button>Restart</button>
</p>
            
          
!
            
              @import "compass/css3";

body{
  font-family: 'Montserrat', sans-serif;
  background:#2980b9;
}

h1{
  color:#fff;
  text-align:center;
}

pre{
	font-family: 'Source Code Pro', monospace;
  margin:2em;
  background:#222;
  color:#aaa;
  border:5px solid #666;
  padding:1em;
  height:300px;
  width:80%;
  max-width:800px;
  margin:2em auto;
}

p{
  text-align:center;
}

button{
  display:inline-block;
  display:none;
  background:#fff;
  border:none;
  border-radius:4px;
  padding:1em;
}
            
          
!
            
              $(function(){
  // The base speed per character
	time_setting = 30;
  // How much to 'sway' (random * this-many-milliseconds)
	random_setting = 100;
  // The text to use NB use \n not real life line breaks!
	input_text = "<div class='main'>\n\t<!-- holy moly I forgot how fast I can type when I get going -->\n\t<h1>Introduction</h1>\n\t<p>Welcome to my website, all about my adventures with code</p>\n</div><!-- .main -->";
  // Where to fill up
	target_setting = $("#output");
  // Launch that function!
	type(input_text, target_setting, 0, time_setting, random_setting);

	$("button").click(function(){
    // When you click, remove the button
		$(this).fadeOut('fast', function(){
      // Remove all the text, then show the pre area again
			target_setting.text("").show();
      // And start again!
			type(input_text, target_setting, 0, time_setting, random_setting);
		});
	});
});

function type(input, target, current, time, random){
  // If the current count is larger than the length of the string, then for goodness sake, stop
	if(current > input.length){
    // Write Complete
		console.log("Complete.");
    // Wait a bit, then do the complete function
		setTimeout(function(){
			finished(input, target, current, time, random);
		},3000);
		
	}
	else{
		console.log(current)
    // Increment the marker
		current += 1;
    // fill the target with a substring, from the 0th character to the current one
		target.text(input.substring(0,current));
    // Wait ...
		setTimeout(function(){
      // do the function again, with the newly incremented marker
			type(input, target, current, time, random);
      // Time it the normal time, plus a random amount of sway
		},time + Math.random()*random);
	}
}

// when its finished
function finished(input, target, current, time, random){
  // fade out the pre
	target.slideUp('fast', function(){
    // fade in the button
		$("button").delay(100).fadeIn('slow');	
	});
}
            
          
!
999px

Console