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.

            
              <div class='left'>
	<div class='lesson'>
		<h1>Box Sizing</h1>
		<p>
			The box sizing property will allow you to change the way in which an elements dimensions are calculated. There are two values that can be used with the box-sizing property: content-box & border-box.
		</p>
		<h4>Content Box</h4>
		<p>
			The content-box value is the default value for the box-sizing property. This value will only include the content of the element into the height and width values. That is to say that the border and padding of an element will not be represented within its height and width. The total amount of space the element will take up will be different from the value of its stored width and height properties.
		</p>
		<p style="text-align: center;"> Actual Width: ELEMENT WIDTH + PADDING + BORDER </p>
		<h4>Border Box</h4>
		<p>
			The border-box value is the other option for the box-sizing property. This value will include both the padding and the border sizings to the content to total the width and height. This means that the value given for the height and width of an element will accurately describe the amount of space the element actually takes up.
		</p>
		<p style="text-align: center;"> Actual Width: ELEMENT WIDTH</p>
		<hr></hr>
		<h4>Example Playground</h4>
		<p>You may have noticed the two gray elements on the page. Both of these elements have the exact same properties, with one execption: box-sizing. Using the inputs below, make changes to the elements' heigth, width, padding, and border properties. Each input controls the properties for both boxes, so any differences between them will be a result of how their dimensions are calculated. Notice particularly how padding and border affect each box differently.</p>
	</div>
	<form>
		<label for="height">
			Height
			<input id="height-input" onchange="onChange()" min='50' max='400' name="height" type="number" value=200>
		</label>
		<label for="width">
			Width
			<input id="width-input" onchange="onChange()" min='50' max='400' name="width" type="number" value=200>
		</label>
		<label for="padding">
			Padding
			<input id="padding-input" onchange="onChange()" min='0' name="padding" type="number" value=0>
		</label>
		<label for="border">
			Border
			<input id="border-input" onchange="onChange()" min='0' name="border" type="number" value=0>
		</label>
	</form>
</div>

<div class="examples">
	<div class="example" id="example--one">
		<p>CONTENT BOX</p>
		<p id='actual-height-one'>Acual Height: 200</p>
		<p id='actual-width-one'>Actual Width: 200</p>
	</div>
	<div class="example" id="example--two">
		<p>BORDER BOX</p>
		<p id='actual-height-two'>Acual Height: 200</p>
		<p id='actual-width-two'>Actual Width: 200</p>
	</div>
</div>
            
          
!
            
              * {
	font-family: 'Rokkitt', serif;
	margin: 0;
	padding: 0;
}
body {
	align-items: center;
	display: flex;
	height: 100vh;
	justify-content: center;
	
}
.left {
	background: #F0F3BD;
	box-shadow: 0 0 40px black;
	width: 50vw;
}

.lesson {
	color: #4B4C3B;
	font-size: 110%;
	padding: 5%;
	width: 90%;
}
.lesson h4 {
	font-size: 120%;
}
.lesson p {
	padding: 5px 0;
}
.lesson hr {
	margin: 10px 0;
}


form {
	border: 2px solid white;
	box-sizing: border-box;
	display: grid;
	grid-gap: 10px;
	grid-template-rows: 1fr 1fr;
	grid-template-columns: 1fr 1fr;
	margin: 5%;
	margin-top: 0;
	padding: 10px;
	text-align: center;
	width: 90%;
}
label {
	font-size: 16px;
}
input {
	font-size: 16px;
	width: 50%;
}


.examples {
	align-items: center;
	display: flex;
	flex-direction: column;
	height: 100vh;
	justify-content: space-around;
	width: 50vw;
}
.example {
	background: #aaa;
	border: 0px solid black;
	height: 200px;
	width: 200px;
	padding: 0px;
	
	align-items: center;
	display: flex;
	flex-direction: column;
	justify-content: center;
}

#example--one {
	box-sizing: content-box;
}
#example--two {
	box-sizing: border-box
}

@media (max-width: 600px) {
	body {
		flex-direction: column;
		height: auto;
	}
	.left {
		box-sizing: border-box;
		width: 100vw;
	}
	.examples {
		min-height: 80vh;
		height: auto;
		width: 100vw;
	}
}
            
          
!
            
              const onChange = () => {
	const height = document.getElementById('height-input').value;
	const width = document.getElementById('width-input').value;
	const padding = document.getElementById('padding-input').value;
	const border = document.getElementById('border-input').value;
	const exampleOne = document.getElementById('example--one');
	const exampleTwo = document.getElementById('example--two');
	const actualHeightOne = document.getElementById('actual-height-one');
	const actualWidthOne = document.getElementById('actual-width-one');
	const actualHeightTwo = document.getElementById('actual-height-two');
	const actualWidthTwo = document.getElementById('actual-width-two');
	
	exampleOne.style.height = height + "px";
	exampleTwo.style.height = height + "px";
	exampleOne.style.width = width + "px";
	exampleTwo.style.width = width + "px";
	exampleOne.style.padding = padding + "px";
	exampleTwo.style.padding = padding + "px";
	exampleOne.style.border = border + "px" + " solid black";
	exampleTwo.style.border = border + "px" + " solid black";
	
	actualHeightOne.innerHTML = "Actual Height: " + (parseInt(height) + (parseInt(padding) * 2) + (parseInt(border) * 2));
	actualWidthOne.innerHTML = "Actual Width: " + (parseInt(width) + (parseInt(padding) * 2) + (parseInt(border) * 2));
	actualHeightTwo.innerHTML = "Actual Height: " + height;
	actualWidthTwo.innerHTML = "Actual Width: " + width;
}
            
          
!
999px

Console