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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <h3>2 columns on mobile, 3 columns on desktop</h3>
<div class="grid grid--one">
  <div class="box box--one">1</div>
  <div class="box box--two">2</div>
  <div class="box box--three">3</div>
  <div class="box box--four">4</div>
  <div class="box box--five">5</div>
  <div class="box box--six">6</div>
  <div class="box box--seven">7</div>
  <div class="box box--eight">8</div>
</div>

<hr />

<h3>Using named lines</h3>
<div class="grid grid--two">
  <div class="box box--one">1</div>
  <div class="box box--two">2</div>
  <div class="box box--three">3</div>
  <div class="box box--four">4</div>
</div> 

<hr />

<h3>Template areas</h3>
<div class="grid grid--three">
  <div class="box box--one">Box 1 - Header</div>
  <div class="box box--two">2</div>
  <div class="box box--three">Box 3 - Main</div>
  <div class="box box--four">4</div>
  <div class="box box--five">Box 5 - Footer</div>
</div>


<hr>

<h3>Named columns and rows</h3>
<div class="grid grid--four">
  <div class="box box--header">Header</div>
  <div class="box box--sidebar">Sidebar</div>
  <div class="box box--main">
    <p>
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione repudiandae quis veniam eius fugiat quasi quas eaque, blanditiis? Autem doloribus itaque, quisquam repudiandae recusandae veniam tenetur. Repudiandae, ex pariatur modi doloribus aut excepturi. Dicta voluptas esse quod accusamus quam harum saepe, porro sint! Totam, autem! Rem odio, illo doloribus ipsam at, vero maiores, veniam hic veritatis velit cum eligendi quam fuga necessitatibus! Ab aut, inventore doloremque. Culpa excepturi eum necessitatibus commodi, consequuntur amet unde, rerum possimus dicta molestiae assumenda vero, quidem ea ipsa minima. Distinctio accusamus libero non laboriosam dolorum veritatis, fugit provident necessitatibus saepe, cumque deleniti, dicta natus sit.
    </p>
  </div>
  <div class="box box--footer">Footer</div>
</div>

<hr>

<h3>One fixed size column + 2 fraction columns</h3>
<div class="grid grid--five">
  <div class="box box--one">Box 1</div>
  <div class="box box--two">Box 2</div>
  <div class="box box--three">Box 3</div>
  <div class="box box--four">Box 4</div>
  <div class="box box--five">Box 5</div>
</div>

<hr>

<h3>Using Minmax</h3>
<div class="grid grid--six">
  <div class="box box--one">Box 1</div>
  <div class="box box--two">Box 2</div>
  <div class="box box--three">Box 3</div>
  <div class="box box--four">Box 4</div>
  <div class="box box--five">Box 5</div>
</div>

              
            
!

CSS

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

body {
  padding: 20px;
}

hr {
  margin-top: 80px;
  margin-bottom: 80px;
}

.grid {
  display: grid;
  grid-gap: 20px;
}

.box {
  width: 100%;
  background: #657075;
  color: #fff;
  padding: 30px;
}


/* First Grid, 2 columns mobile, 3 columns desktop  */

.grid--one {
  /* Using 2 columns layout on small screens (media query below) */
  grid-template-columns: 1fr 1fr; 
  /* Grids will be auto generated as needed */
  grid-template-rows: auto;
}

.grid--one .box--one {
  /* shorthand for grid-rows: 1 / 3 and grid-columns 1 / 3. The order is row start / column start / row end / column end */
  grid-area: 1 / 1 / 3 / 3;
}

@media (min-width: 768px) {
  .grid--one {
    /* Using 3 columns layout on large screens, grids allow us to do this trick */
    /* we could simply rollout a 12 columns layout */
    grid-template-columns: repeat(3, 1fr);
  }
  .grid--one .box--one {
    /* the numbers are the starting LINE and ending LINE (not the track, which is the grid cell itself) */
    grid-column: 1 / 4;
    grid-row: 1 / 3;
  }
  .grid--one .box--two {
    /* shorthand for grid-rows and grid columns. The order is row start / column start / row end / column end */
    grid-area: 3 / 1 / 7 / 3;
  }
  .grid--one .box--three {
    grid-area: 3 / 3 / 6 / 4;
  }
}



/* Styles for the second grid box using named lines */

.grid--two {
  display: grid;
  /* Giving a name to our lines makes it easier to detect them */
  /*  The following will still take 3 rows, but we are naming the lines */
  grid-template-rows: [header-start] 1fr 
                      [body-start] 1fr 1fr 
                      [body-end];
  /*  Same for the columns, we are naming the lines and we have 3 columns in totals */
  grid-template-columns: [side-start] 1fr 
                         [body-start] 1fr 1fr 
                         [body-end];
}

.grid--two .box--one {
  grid-area: header-start / side-start / body-start / body-end;
}

.grid--two .box--two {
  /*  If you name lines with "something-start" and "something-end" you can then use something as your area */
  /* In this case this is equivalent to writing   
    grid-area: body-start / body-start / body-end / body-end;
  */
  grid-area: body;
}


/* Styles for the third grid box using template areas */

.grid--three {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto;
  grid-template-areas: "header header header"
                       "side2 main main"
                       "side2 main main"
                       ". footer footer"
  /* the dot is used for white space */
}

.grid--three .box--one {
  grid-area: header;
}

.grid--three .box--three {
  grid-area: main;
}

.grid--three .box--five {
  grid-area: footer;
}


/* Fourth box using named lines for both rows and columns */

.grid--four {
  display: grid;
  grid-template-columns: [side-start ] 2fr [main-start] 4fr [main-end];
  grid-template-rows: [header-start] auto
                      [content-start] auto
                      [sidebar-start] auto
                      [footer-start] auto [footer-end]
}

.grid--four .box--header {
  grid-column: side-start / main-end;
  grid-row: header-start;
}

.grid-four .box--sidebar {
  grid-column: side-start;
  grid-row: content-start;
}

.grid-four .box--main {
  grid-column: main-start;
  grid-row: content-start;
}

.grid--four .box--footer {
  grid-column: side-start / main-end;
  grid-row: footer-start;
}


/* Fifth grid with a fixed width column followed by 2 columns which divide up the available space */


.grid--five {
  grid-template-columns: 400px 1fr 1fr;
  grid-gap: 20px;
}


/* Sixth grid showing the repeat featuren and the minmax feature - the columns will never be less than 200px */


.grid--six {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
              
            
!

JS

              
                
              
            
!
999px

Console