css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm 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. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

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.

            
              <h1>Grid Layout with CSS variables</h1>

<p>going beyond CSS grid frameworks</p>
<section class="grid-4-gutter-1">
  <div></div>
  <div class="col-span"></div>
  <div class="row-span"></div>
  <div></div>
  <div></div>
  <div class="first"> .first</div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</section>

<section class="content">
<h2>including:</h2>
<ul>
  <li>CSS grid layout spec</li>
  <li>repeating elements : repeat()</li>
  <li>grid-gap</li>
  <li>autoflow elements</li>
  <li>CSS custom properties <a href="http://caniuse.com/#feat=css-variables">(variables)</a></li>
  <li>= perfect grid ♥</li>
</ul>
</section>

<section class="content">
<h2>browser support:</h2>
<ul>
  <li>Edge 16</li>
  <li>Chrome 50</li>
  <li>Firefox 46</li>
  <li>Opera <a href="https://igalia.github.io/css-grid-layout/enable.html">(flag)</a></li>
  <li>Safari : <a href="https://www.chromestatus.com/feature/4589636412243968">in development</a></li>
</ul>
</section>

<p>spec : <a href="https://www.w3.org/TR/css3-grid-layout/">CSS Grid Layout Module Level 1</a></p>

<p>source : <a href="https://blog.goetter.fr/2016/01/02/grid-layout-vers-la-grille-parfaite/">Grid Layout, vers la grille parfaite</a></p>
            
          
!
            
              /* Layout */

[class*="grid-"] {
  --grid-number: 1; /* base value */
  --grid-gutter: 0; /* base value */
  display: grid; /* grid container */
  grid-template-columns: repeat(var(--grid-number), 1fr);
  grid-gap: var(--grid-gutter); /* vertical and horizontal gutter */
}

/* Grid number */
[class*="grid-6"] {
  --grid-number: 6;
}
[class*="grid-5"] {
  --grid-number: 5;
}
[class*="grid-4"] {
  --grid-number: 4;
}
[class*="grid-3"] {
  --grid-number: 3;
}
[class*="grid-2"] {
  --grid-number: 2;
}
[class*="grid-1"] {
  --grid-number: 1;
}

/* Grid gutter */
[class*="-gutter-4"] {
  --grid-gutter: 4rem;
}
[class*="-gutter-3"] {
  --grid-gutter: 3rem;
}
[class*="-gutter-2"] {
  --grid-gutter: 2rem;
}
[class*="-gutter-1"] {
  --grid-gutter: 1rem;
}
[class*="no-gutter"] {
  --grid-gutter: 0;
}

/* Grid items order */

.first {
  order: -1; /* will be first item */
}

@media (min-width: 481px) {
  .col-span {
    grid-column: auto / span 2; /* will be double sized horizontally */
  }
  .row-span {
    grid-row: auto / span 2; /* will be double sized vertically */
  }
}

/* Responsive small */
@media (max-width: 640px) {
[class*="grid-"] {
    grid-template-columns: repeat(2, 1fr);
  }
}
/* Responsive tiny */
@media (max-width: 480px) {
[class*="grid-"] {
    grid-template-columns: 1fr;
  }
  .content {
    width: auto;
  }
}


/* Counter */
div {
  counter-increment: number;
}
div::before {
  content: counter(number);
}

/* Decoration */

* {
  box-sizing: border-box;
}
body {
	margin: 20px;
	background: #fff;
	font-family: arial, sans-serif;
	font-size: 1.2em;
}
.content {
  width: 60%;
  margin: 2rem auto;
  padding-left: 1rem;
  border-left: 6px solid #bada55;
  text-align: left;
}
[class*="grid-"] {
	background: beige;
	border: 3px dotted orange;
	padding: 1rem;
}
ul {
  padding: 0;
  color: gray;
}
li {
  list-style: none;
  text-align: left;
}
p {
  text-align: center;
  color: gray;
}
a {color: inherit}
div {
	padding: 1rem;
	color: #fff;
}
div:nth-of-type(odd) {
	background: tan;
}
div:nth-of-type(even) {
	background: peru;
}

h1 {
	margin: 0 0 1em;
	color: #345;
	text-align: center;
  font-family: georgia, "trebuchet ms", arial, serif;
}
h2 {
  display: inline-block;
	margin: 0;
	color: #789;
  font-family: georgia, "trebuchet ms", arial, serif;
}



            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console