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 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

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.

HTML

              
                <header class="o-container">
	<h1>Grid v6</h1>
</header>

<div class="_reference"></div>
<div class="o-container">
	<div class="c-example o-grid">
		<div class="c-example__block o-grid__column u-span-4@tablet">
			Column #1
		</div>
		<div class="c-example__block c-example__block--with-image o-grid__column u-span-4@tablet u-background-bleed-full@tablet">
			Column #2
			<div class="_magic">Hello</div>
		</div>
		<div class="c-example__block o-grid__column u-span-4@tablet">
			Column #3
		</div>
	</div><!-- /.o-grid -->
</div><!-- /.o-container -->

<!-- Old syntax... -->
<!-- <div class="c-example__block o-grid__column u-span-4@tablet u-background-blue"> -->
<!-- <div class="o-grid__column u-span-4@tablet u-background-green u-background-bleed-full"> -->
<!-- <div class="c-example__block o-grid__column u-span-4@tablet u-background-blue"> -->

<h2>Richie's Wild & Crazy Example</h2>
<div class="_reference"></div>
<div class="o-container">
	<div class="o-grid">
		<div class="o-grid__column u-span-4 u-background-blue u-background-bleed-full-right" style="padding: 1rem;">
			<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sint quaerat tenetur quisquam aliquid excepturi accusamus, voluptatum quos enim sequi, non ab hic placeat. Suscipit quae ex quo fuga praesentium soluta?</p>
			<img src="https://placehold.it/300x200" alt=""
				style="display: block; width: calc(100% + 2rem + 24px); margin-left: calc(-1rem);">
			<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Adipisci accusantium necessitatibus, iure odio excepturi harum earum ipsam eum velit nihil dolor, aut corporis nulla qui incidunt debitis! Molestias, dolores numquam!</p>
		</div>
		<div class="o-grid__column u-span-4 u-background-green" style="padding: 1rem;">Hello!</div>
		<div class="o-grid__column u-span-4 u-background-blue" style="padding: 1rem;">Hello!</div>
	</div>
</div>

              
            
!

CSS

              
                .o-grid__column {
	outline: 1px dotted black;
}

/* ------------------------------ */
/* Ideas                          */
/* ------------------------------ */
/* 
- Use `u-background` instead of `u-background-color` so that
    it's easy to include images, gradients, etc.
- Use `--background` variable on both the column and the utility
    (instead of adding a new `.var-` namespace) so that it's 
    easy to apply backgrounds as needed.
 */

/* ------------------------------ */
/* Base                           */
/* ------------------------------ */

:root {
	--page-padding: 30px;
	--gutter-width: 24px;
}

html {
	box-sizing: border-box;
}

*,
::after,
::before {
	box-sizing: inherit;
}

body {
	margin: 1rem 0 10rem;
}

main {
	margin: 1rem auto;

	/* DEBUG */
	/* width: 1200px; */
	/* outline: 1px dashed blue; */
}

/* ------------------------------ */
/* Container                      */
/* ------------------------------ */

.o-container {
	padding-right: var(--page-padding);
	padding-left: var(--page-padding);
}

/* ------------------------------ */
/* Grid                           */
/* ------------------------------ */

.o-grid {
	--span-width: calc(
		(100% - var(--gutter-width) * 12) / 12
	);
	display: flex;
	flex-wrap: wrap;
	margin-left: calc(var(--gutter-width) * -1);
}

.o-grid__column {
	flex: 0 0 auto;
	margin-left: var(--gutter-width);
	background: var(--background);

	/* DEBUG */
	/* outline: 1px dotted black; */
}

[class*="u-span-"] {
	--span: 12;
	width: calc(
		var(--span-width) * var(--span) +
		var(--gutter-width) * (var(--span) - 1)
	);
}

.u-span-1 { --span: 1; }
.u-span-2 { --span: 2; }
.u-span-3 { --span: 3; }
.u-span-4 { --span: 4; }
.u-span-5 { --span: 5; }
.u-span-6 { --span: 6; }
.u-span-7 { --span: 7; }
.u-span-8 { --span: 8; }
.u-span-9 { --span: 9; }
.u-span-10 { --span: 10; }
.u-span-11 { --span: 11; }
.u-span-12 { --span: 12; }

@media (min-width: 768px) {
	.u-span-1\@tablet { --span: 1; }
	.u-span-2\@tablet { --span: 2; }
	.u-span-3\@tablet { --span: 3; }
	.u-span-4\@tablet { --span: 4; }
	.u-span-5\@tablet { --span: 5; }
	.u-span-6\@tablet { --span: 6; }
	.u-span-7\@tablet { --span: 7; }
	.u-span-8\@tablet { --span: 8; }
	.u-span-9\@tablet { --span: 9; }
	.u-span-10\@tablet { --span: 10; }
	.u-span-11\@tablet { --span: 11; }
	.u-span-12\@tablet { --span: 12; }
}

/* ------------------------------ */
/* Background Bleed               */
/* ------------------------------ */

[class*="u-background-bleed"] {
	position: relative;
	z-index: 1;
}

[class*="u-background-bleed"]::before {
	content: '';
	position: absolute;
	top: 0;
	right: calc(var(--gutter-width) * -1 / 2);
	bottom: 0;
	left: calc(var(--gutter-width) * -1 / 2);
	background: var(--background);
	z-index: -1;
}

[class*="u-background-bleed-full"]::before {
	right: calc(var(--gutter-width) * -1);
	left: calc(var(--gutter-width) * -1);
}

.u-background-bleed-right::before,
.u-background-bleed-full-right::before {
	left: 0;
}

.u-background-bleed-left::before,
.u-background-bleed-full-left::before {
	right: 0;
}

@media (max-width: 767px) {
	.u-background-bleed\@tablet::before,
	.u-background-bleed-full\@tablet::before {
		right: 0;
		left: 0;
	}
}

/* ------------------------------ */
/* Variables                      */
/* ------------------------------ */

/* .var-background-blue { */
.u-background-blue {
	--background: lightblue;
	background: lightblue;
}

/* .var-background-green { */
.u-background-green {
	--background: lightgreen;
	background: lightgreen;
}

/* ------------------------------ */
/* Components                     */
/* ------------------------------ */

.c-example {
	height: 300px;
	
	/* ❓ Is there a way to make a variable important?
	    I guess not. I guess that wouldn't make sense,
	    though doesn't make sense, since variables
	    are scoped... Besides, you shouldn't be trying
	    to override utilities (at least, not outside
	    of a test).
	 */
	/* --background: blue !important; */
}

.c-example__block {
	--background: lightblue;
	padding: 1rem;
}

.c-example__block--with-image {
	--background:
		url('https://images.unsplash.com/photo-1564053051381-5cb91813736b?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ')
		center / cover no-repeat;
	color: white;

	@media (min-width: 768px) {
		padding-right: 0;
		padding-left: 0;
	}
}

._magic {
	position: absolute;
	top: 3rem;
	right: 0;
	/* 💡 Make helper for applying grid spans to custom components */
	/* width: span(1); */
	width: 73px;
	background: yellow;
	color: black;
	padding: 1rem;
}

/* ------------------------------ */
/* Demo Styles                    */
/* ------------------------------ */

._reference {
	/* Total Width = 1200px */
	/* Page Padding = 30px */
	/* Gutter = 24px */
	/* 1200px = (30px * 2) + (24px * 11) + 12x */
	/* (1200px - 60px - 264px) / 12 = x */
	/* 876px / 12 = x */
	/* 73px = x */
	--span-width: 73px;
	width: 1200px;
	height: 2rem;
	margin: auto;
	background: linear-gradient(
		to right,
		/* Page Padding Left */
		red 0px,
		red calc(var(--page-padding)),
		/* Column 1 */
		#eee calc(var(--page-padding)),
		#eee calc(var(--page-padding) + var(--span-width)),
		/* Gutter 1 */
		pink calc(var(--page-padding) + var(--span-width)),
		pink calc(var(--page-padding) + var(--span-width) + var(--gutter-width)),
		/* Column 2 */
		#eee calc(var(--page-padding) + var(--span-width) + var(--gutter-width)),
		#eee calc(var(--page-padding) + var(--span-width) * 2 + var(--gutter-width)),
		/* Gutter 2 */
		pink calc(var(--page-padding) + var(--span-width) * 2 + var(--gutter-width)),
		pink calc(var(--page-padding) + var(--span-width) * 2 + var(--gutter-width) * 2),
		/* Column 3 */
		#eee calc(var(--page-padding) + var(--span-width) * 2 + var(--gutter-width) * 2),
		#eee calc(var(--page-padding) + var(--span-width) * 3 + var(--gutter-width) * 2),
		/* Gutter 3 */
		pink calc(var(--page-padding) + var(--span-width) * 3 + var(--gutter-width) * 2),
		pink calc(var(--page-padding) + var(--span-width) * 3 + var(--gutter-width) * 3),
		/* Column 4 */
		#eee calc(var(--page-padding) + var(--span-width) * 3 + var(--gutter-width) * 3),
		#eee calc(var(--page-padding) + var(--span-width) * 4 + var(--gutter-width) * 3),
		/* Gutter 4 */
		pink calc(var(--page-padding) + var(--span-width) * 4 + var(--gutter-width) * 3),
		pink calc(var(--page-padding) + var(--span-width) * 4 + var(--gutter-width) * 4),
		/* Column 5 */
		#eee calc(var(--page-padding) + var(--span-width) * 4 + var(--gutter-width) * 4),
		#eee calc(var(--page-padding) + var(--span-width) * 5 + var(--gutter-width) * 4),
		/* Gutter 5 */
		pink calc(var(--page-padding) + var(--span-width) * 5 + var(--gutter-width) * 4),
		pink calc(var(--page-padding) + var(--span-width) * 5 + var(--gutter-width) * 5),
		/* Column 6 */
		#eee calc(var(--page-padding) + var(--span-width) * 5 + var(--gutter-width) * 5),
		#eee calc(var(--page-padding) + var(--span-width) * 6 + var(--gutter-width) * 5),
		/* Gutter 6 */
		pink calc(var(--page-padding) + var(--span-width) * 6 + var(--gutter-width) * 5),
		pink calc(var(--page-padding) + var(--span-width) * 6 + var(--gutter-width) * 6),
		/* Column 7 */
		#eee calc(var(--page-padding) + var(--span-width) * 6 + var(--gutter-width) * 6),
		#eee calc(var(--page-padding) + var(--span-width) * 7 + var(--gutter-width) * 6),
		/* Gutter 7 */
		pink calc(var(--page-padding) + var(--span-width) * 7 + var(--gutter-width) * 6),
		pink calc(var(--page-padding) + var(--span-width) * 7 + var(--gutter-width) * 7),
		/* Column 8 */
		#eee calc(var(--page-padding) + var(--span-width) * 7 + var(--gutter-width) * 7),
		#eee calc(var(--page-padding) + var(--span-width) * 8 + var(--gutter-width) * 7),
		/* Gutter 8 */
		pink calc(var(--page-padding) + var(--span-width) * 8 + var(--gutter-width) * 7),
		pink calc(var(--page-padding) + var(--span-width) * 8 + var(--gutter-width) * 8),
		/* Column 9 */
		#eee calc(var(--page-padding) + var(--span-width) * 8 + var(--gutter-width) * 8),
		#eee calc(var(--page-padding) + var(--span-width) * 9 + var(--gutter-width) * 8),
		/* Gutter 9 */
		pink calc(var(--page-padding) + var(--span-width) * 9 + var(--gutter-width) * 8),
		pink calc(var(--page-padding) + var(--span-width) * 9 + var(--gutter-width) * 9),
		/* Column 10 */
		#eee calc(var(--page-padding) + var(--span-width) * 9 + var(--gutter-width) * 9),
		#eee calc(var(--page-padding) + var(--span-width) * 10 + var(--gutter-width) * 9),
		/* Gutter 10 */
		pink calc(var(--page-padding) + var(--span-width) * 10 + var(--gutter-width) * 9),
		pink calc(var(--page-padding) + var(--span-width) * 10 + var(--gutter-width) * 10),
		/* Column 11 */
		#eee calc(var(--page-padding) + var(--span-width) * 10 + var(--gutter-width) * 10),
		#eee calc(var(--page-padding) + var(--span-width) * 11 + var(--gutter-width) * 10),
		/* Gutter 11 */
		pink calc(var(--page-padding) + var(--span-width) * 11 + var(--gutter-width) * 10),
		pink calc(var(--page-padding) + var(--span-width) * 11 + var(--gutter-width) * 11),
		/* Column 12 */
		#eee calc(var(--page-padding) + var(--span-width) * 11 + var(--gutter-width) * 11),
		#eee calc(var(--page-padding) + var(--span-width) * 12 + var(--gutter-width) * 11),
		/* Page Padding Right */
		red calc(var(--page-padding) + var(--span-width) * 12 + var(--gutter-width) * 11),
		red 100%
	);
}

              
            
!

JS

              
                
              
            
!
999px

Console