Pen Settings



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


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


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.


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.

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.


	<h1>How to Contain Images</h1>
	<p>Simple rules to define boundaries around an image.</p>
	<p>For example, make sure the container is at least 150px wide but no more than 280px wide and 70px tall, and let the image grow/shrink to fit within the space.</p>
	<p>(Similar to <code>object-fit: contain;</code>, but this works in Internet Explorer.)</p>

	<h2>Example #1: Horizontal Image</h2>
	<div class="logo-container">
		<img class="logo-container__image" src="" alt="">

	<h2>Example #2: Vertical Image</h2>
	<div class="logo-container">
		<img class="logo-container__image" src="" alt="">
	<h2>Note on SVGs</h2>
	<p>For this technique to work, your image <em>needs</em> an intrinsic <code>width</code> or <code>height</code>. Otherwise, it will not force the container to grow. Without the container’s <code>min-width</code> the image would render 0px by 0px.</p>
	<p>So make sure your SVG has <code>width</code> and <code>height</code> defined (and <code>viewBox</code> too!).</p>



                // ------------------------------
// Base
// ------------------------------

html {
	box-sizing: border-box;

::before {
	box-sizing: inherit;

body {
	margin: 1rem auto 3rem;
	line-height: 1.4;
	tab-size: 4;

main {
	display: block; // Fix IE rendering main as inline
	margin: 0 auto;
	max-width: 38rem;
	padding-left: 1rem;
	padding-right: 1rem;

// ------------------------------
// Logo Container
// ------------------------------

$container-min-width: 150px;
$container-max-width: 280px;
$container-max-height: 70px;
$container-padding-top: 5px;
$container-padding-bottom: 5px;
$container-padding-horizontal: 20px;

.logo-container {
	display: inline-block;
	max-width: $container-max-width; // 1. Put max-width on the container
	min-width: $container-min-width;
	padding: $container-padding-top $container-padding-horizontal $container-padding-bottom;
	background: blue;

.logo-container__image {
	display: block;
	max-width: 100%;
	max-height: $container-max-height - $container-padding-top - $container-padding-bottom; // 2. Put max-height on the image
	margin: auto;