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

              
                <article>
	<h1>Boilerplate for Grids</h1>
	<section>
		<h2>1. Floated items</h2>
		<div class="grid grid-floated">
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
		</div><!-- .grid -->
		<h2>2. Inline-block items</h2>
		<div class="grid grid-ib">
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
		</div><!-- .grid -->
		<h2>3. Flexbox — single row</h2>
		<div class="grid grid-flex">
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
		</div><!-- .grid -->
		<h2>4. Flexbox with float fallback</h2>
		<div class="grid grid-floated grid-flex">
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
		</div><!-- .grid -->
		<h2>5. Flexbox with inline-block fallback</h2>
		<div class="grid grid-ib grid-flex">
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
			<div class="grid-size-1of5">
				<div class="grid-content">1/5</div>
			</div>
		</div><!-- .grid -->
		<h2>6. Two column layout (flex + floats)</h2>
		<div class="grid grid-floated grid-flex">
			<div class="grid-golden-1">
				<div class="grid-content">62%</div>
			</div>
			<div class="grid-golden-2">
				<div class="grid-content">38%</div>
			</div>
		</div><!-- .grid -->
		<h2>7. Two column layout (flex + inline-blocks)</h2>
		<div class="grid grid-ib grid-flex">
			<div class="grid-golden-1">
				<div class="grid-content">62%</div>
			</div>
			<div class="grid-golden-2">
				<div class="grid-content">38%</div>
			</div>
		</div><!-- .grid -->
	</section>
</article>

              
            
!

CSS

              
                * {
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}

html { background-color: #666; }

body {
	width: 90%;
	margin: 1.5em auto;
	padding: 24px;
	background-color: #f0f0f0;
	color: #000;
}

/* Establish block-formatting context to contain floats and margins */
section {
	display: inline-block;
	width: 100%;
}

/* gutter of 20px; margin-left puts 10px before and after */
.grid {
	width: 100%;
	margin-left: -10px;
	margin-bottom: 1.5em;
}

/* padding-left creates gutter */
.grid > * {
	padding-left: 20px;
}

/* Clear floats */
.grid-content {
	padding: .75em;
	background-color: #c4c4c4;
	background-color: rgba(153, 153, 153, .5);

}

/* styles for floated layout */
.grid-floated:after {
	content: '';
	display: table;
	clear: both;
}

.grid-floated > * {
	float: left;
}

/*	Styles for inline-block layout */
/*	Note: Most, but not all browsers eliminate the single space between each inline-block. Using white-space:nowrap; prevents the grids wrapping, at the expense of a slightly wider grid. */
.grid-ib {
	font-size: 0;
	white-space: nowrap;
}

/* Be sure to reset these "fixes" */
.grid-ib > * {
	display: inline-block;
	font-size: 16px;
	font-size: 1rem;
	white-space: normal;
}

/* Styles for flex layout */
/* 	Note: display:-webkit-box is an old version of flexbox used by Safari 5 (Windows) and Android. It does not play well with floats and inline-blocks, so is omitted. */
.grid-flex {
	display: -ms-flexbox;	/* IE 10 */
	display: -webkit-flex;	/* Opera 15-16 */
	display: flex;			/* IE 11; FF 22+; Opera 12.1, 17+; Chrome 29+ */
}

/* Grid element sizes */
.grid-size-1of5 { width: 20%; }
.grid-size-1of3 { width: 33.3%; }
.grid-golden-1 { width: 62%; }
.grid-golden-2 { width: 38%; }

/* Fall back to single column for narrow widths */
@media (max-width:40em) {
	.grid {
		display: block;
	}

	.grid > * {
		width: 100%;
		margin-bottom: 1.5em;
	}
}

/* IE 7 support if you need it */
.grid-ib > * {
	*display: inline;
}

.grid-content {
	*background-color: #c4c4c4;
}

.grid-size-1of5 {
	width: expression((this.parentNode.clientWidth/5 - parseInt(this.currentStyle['paddingLeft']) - parseInt(this.currentStyle['paddingRight'])) + 'px');
}

.grid-size-1of3 {
	width: expression((this.parentNode.clientWidth/3 - parseInt(this.currentStyle['paddingLeft']) - parseInt(this.currentStyle['paddingRight'])) + 'px');
}

.grid-golden-1 {
	width: expression((this.parentNode.clientWidth*0.62 - parseInt(this.currentStyle['paddingLeft']) - parseInt(this.currentStyle['paddingRight'])) + 'px');
}

.grid-golden-2 {
	width: expression((this.parentNode.clientWidth*0.38 - parseInt(this.currentStyle['paddingLeft']) - parseInt(this.currentStyle['paddingRight'])) + 'px');
}

              
            
!

JS

              
                /** If you use Modernizr to detect support for flex, you could add this rule to prevent float drop that may occur with percent widths on floats:

.no-flexbox .grid-last {
  float: none;
  overflow: hidden;
  width: auto;
 }
 
 Where .grid-last class is added to the final column.
 See the answer to "How does ez-css work?" here:
 http://www.ez-css.org/faq
*/
              
            
!
999px

Console