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

              
                <div id="container">
	<header>
		<h1 id="title">
	  Allow Users to Change Font Size
	</h1>

		<p>Click the buttons to see it in action</p>
		<div class="textcontrols">
			<button role="button" id="decreasetext" <span>smaller</span>
			</button>
			<button role="button" id="resettext">
				<span>normal</span>
			</button>
			<button role="button" id="increasetext">
				<span>bigger</span>
			</button>
		</div>
		<!--/.textcontrols-->
	</header>
	<main id="content" role="main">
		<div id="description">
			<h2>Allow users to resize text on the page via button controls.</h2>
			<p>In this instance, users can decrease text, increase text, or reset it back to normal.</p>
			<h2>Set default text size with CSS</h2>
			<p>The default text size must be set using an internal stylesheet in the header of your page. In this case: <code>font-size: 1.125em</code> (aka, 18px).</p>
			<h2>Set the controls with JavaScript</h2>
			<p>Then we set the resize controls with JavaScript. In this example, we're resizing all text within the div with an id of "content".</p>
			<p>The controls check the current text size, and then changes it (or not) accordingly.</p>
		</div>
		<!--/#description-->
	</main>
	<!--/#content-->
</div>
<!--/#container-->
              
            
!

CSS

              
                header {
	text-align: center;
}


/* text-controls */

button {
	vertical-align: bottom;
	margin: 0 0.3125em;
	padding: 0 0.3125em;
	border: 1px solid #000;
	background-color: #fff;
	font-weight: bold;
}

button#increasetext {
	font-size: 1.50em;
}

button#resettext {
	font-size: 1.25em;
}

button#decreasetext {
	font-size: 1.125em;
}

.textcontrols {
	padding: 0.625em 0;
	background: #ccc;
}


/* content */

#content {
	margin: 3em 0;
	text-align: left;
}


/* demo container */

#container {
	width: 90%;
	margin: 0 auto;
	padding: 2%;
}

#description {
	margin-bottom: 1.25em;
	text-align: left;
}

@media all and (min-width: 700px) {
	#container {
		width: 700px;
	}
	button {
		margin: 0 0.625em;
		padding: 0 0.625em;
	}
}
              
            
!

JS

              
                	// Increase/descrease font size
	$('#increasetext').click(function() {
		curSize = parseInt($('#content').css('font-size')) + 2;
		if (curSize <= 32)
			$('#content').css('font-size', curSize);
	});

	$('#resettext').click(function() {
		if (curSize != 18)
			$('#content').css('font-size', 18);
	});

	$('#decreasetext').click(function() {
		curSize = parseInt($('#content').css('font-size')) - 2;
		if (curSize >= 14)
			$('#content').css('font-size', curSize);
	});
              
            
!
999px

Console