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 v7</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>
		<div class="c-example__block o-grid__column u-span-4@tablet">Column #3</div>
		<div class="c-example__block o-grid__column u-span-4@tablet">Column #4</div>
		<div class="c-example__block o-grid__column u-span-4@tablet">Column #5</div>
		<div class="c-example__block o-grid__column u-span-4@tablet">Column #6</div>
		<div class="c-example__block o-grid__column u-span-4@tablet">Column #7</div>
		<div class="c-example__block o-grid__column u-span-4@tablet">Column #8</div>
		<div class="c-example__block o-grid__column u-span-4@tablet">Column #9</div>
		<div class="c-example__block o-grid__column u-span-4@tablet">Column #10</div>
		<div class="c-example__block o-grid__column u-span-4@tablet">Column #11</div>
		<div class="c-example__block o-grid__column u-span-4@tablet">Column #12</div>
	</div><!-- /.o-grid -->
</div><!-- /.o-container -->

<!--
P.S. The v1.2.0 release of Tailwind is going to be _glorious_.
https://github.com/tailwindcss/tailwindcss/releases/tag/v1.2.0-canary.4
-->
              
            
!

CSS

              
                /* ------------------------------ */
/* 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 {
	display: grid;
	grid-template-columns: repeat(12, 1fr);
	grid-gap: var(--gutter-width);
}

.o-grid__column {
	/* Make columns full-width by default */
	--span: 12;
	
	/* 💡 Use `span` keyword, same as Tailwind */
	/* https://github.com/tailwindcss/tailwindcss/pull/1274 */
	grid-column: span var(--span) / span var(--span);

	/* Prevent content from expanding columns */
	min-width: 0;
	
	/* DEMO */
	background: var(--background);
	outline: 1px dotted black;
}

.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                      */
/* ------------------------------ */

.u-background-blue {
	--background: lightblue;
	background: lightblue;
}

.u-background-green {
	--background: lightgreen;
	background: lightgreen;
}

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

.c-example {
	height: 300px;
}

.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;
	} */
}

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