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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <div class="outer-container">
  
  <h2>Basic (12 column)</h2>

  <div class="grid-container">

    <div class="grid-column grid-column--12">
      <code>@include grid-column;</code>
    </div>

  </div>

  <div class="grid-container">

    <div class="grid-column grid-column--6">
      <code>@include grid-column(6);</code>
    </div>

    <div class="grid-column grid-column--6">
      <code>@include grid-column(6);</code>
    </div>

  </div>

  <div class="grid-container">

    <div class="grid-column grid-column--4">
      <code>@include grid-column(4);</code>
    </div>

    <div class="grid-column grid-column--4">
      <code>@include grid-column(4);</code>
    </div>

    <div class="grid-column grid-column--4">
      <code>@include grid-column(4);</code>
    </div>

  </div>

  <h2>Custom column totals</h2>
  
  <div class="grid-container">

    <div class="grid-column grid-column--1-of-5">
      <code>@include grid-column(1 of 5);</code>
    </div>

    <div class="grid-column grid-column--1-of-5">
      <code>@include grid-column(1 of 5);</code>
    </div>
      
    <div class="grid-column grid-column--1-of-5">
      <code>@include grid-column(1 of 5);</code>
    </div>
      
    <div class="grid-column grid-column--1-of-5">
      <code>@include grid-column(1 of 5);</code>
    </div>
      
    <div class="grid-column grid-column--1-of-5">
      <code>@include grid-column(1 of 5);</code>
    </div>

  </div>
  
  <div class="grid-container">
        
    <div class="grid-column grid-column--1-of-7">
      <code>@include grid-column(1 of 7);</code>
    </div>
        
    <div class="grid-column grid-column--4-of-7">
      <code>@include grid-column(4 of 7);</code>
    </div>
        
    <div class="grid-column grid-column--2-of-7">
      <code>@include grid-column(2 of 7);</code>
    </div>
        
  </div>
  
  <h2>Nested grids</h2>
  
  <h3>Normal</h3>
  
  <div class="grid-container">

    <div class="grid-column grid-column--6">

      <div class="grid-container">

        <div class="grid-column grid-column--3-of-6">
          <code>@include grid-column(3 of 6);</code>
        </div>

        <div class="grid-column grid-column--3-of-6">
          <code>@include grid-column(3 of 6);</code>
        </div>

      </div>

    </div>

    <div class="grid-column grid-column--6">

      <div class="grid-container">

        <div class="grid-column grid-column--6">
          <code>@include grid-column(6);</code>
        </div>

        <div class="grid-column grid-column--6">
          <code>@include grid-column(6);</code>
        </div>

      </div>

    </div>

  </div>
  
  <h3>Collapsed grid containers</h3>

  <div class="grid-container">

    <div class="grid-column grid-column--6">

      <div class="grid-container grid-collapse">

        <div class="grid-column grid-column--1-of-2">
          <code>@include grid-column(1 of 2);</code>
        </div>

        <div class="grid-column grid-column--1-of-2">
          <code>@include grid-column(1 of 2);</code>
        </div>

      </div>

    </div>

    <div class="grid-column grid-column--6">

      <div class="grid-container grid-collapse">

        <div class="grid-column grid-column--3-of-5">
          <code>@include grid-column(3 of 5);</code>
        </div>

        <div class="grid-column grid-column--2-of-5">
          <code>@include grid-column(2 of 5);</code>
        </div>

      </div>

    </div>

  </div>
  
  <h2>Common mistakes</h2>
  
  <h3>Elements as both columns and containers</h3>
  
  <div class="grid-container">
    
    <div class="grid-column grid-container">
      
      <div class="grid-column grid-column--6"></div>
    
      <div class="grid-column grid-column--6"></div>
      
    </div>
    
  </div>
  
  <h3>Children of grid-container that aren't grid-column</h3>
  
   <div class="grid-container">
    
     <div class="box">
       <p>This is box won't align with other grid elements.</p>
     </div>
    
  </div>
  
  <h3>Applying grid collapse to the top level container</h3>
  
  <div class="grid-container grid-collapse">
    
     <div class="box">
       <p>This is box won't align with other grid elements.</p>
     </div>
    
  </div>
  
  <h3>Using grids when you don't need to!</h3>
  
  <div class="grid-container">
    
     <div class="box">
       <p>Not everything has to be in a container or column. Are there more appropriate ways that you can build the layout? E.g. flex?</p>
     </div>
    
  </div>
  
</div>
              
            
!

CSS

              
                @import "neat@2.0";

body {
  margin: 0;
  font-size: 20px;
  font-family: monospace;
  text-align: center;
}

* {
  box-sizing: border-box;
}

.outer-container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 20px 0;
  background-color: darkseagreen;
}

.grid-container {
  
  // all grid-columns should be wrappeed in a container element.
  @include grid-container;
  
  &.grid-collapse {
    
    // this removes the outer margins of the container, 
    // for use with nested grids.
    @include grid-collapse;
  }
}

.grid-column {
  
  background-color: tomato;
  height: 200px;
  margin-bottom: 20px;
  
  .grid-column {
    background-color: orange;
  } 
  
  &.grid-column--12 {
    @include grid-column;
  }
  
  &.grid-column--6 {
    @include grid-column(6);
  }
  
  &.grid-column--4 {
    @include grid-column(4);
  }
  
  &.grid-column--1-of-2 {
    @include grid-column(1 of 2);
  }
  
  &.grid-column--1-of-5 {
    @include grid-column(1 of 5);
  }
  
  &.grid-column--1-of-7 {
    @include grid-column(1 of 7);
  }
  
  &.grid-column--2-of-7 {
    @include grid-column(2 of 7);
  }
  
  &.grid-column--4-of-7 {
    @include grid-column(4 of 7);
  }
  
  &.grid-column--3-of-6 {
    @include grid-column(3 of 6);
  }
  
  &.grid-column--3-of-5 {
    @include grid-column(3 of 5);
  }
  
  &.grid-column--2-of-5 {
    @include grid-column(2 of 5);
  }
}

.box {
  background-color: lavender;
  padding: 20px;
}
              
            
!

JS

              
                
              
            
!
999px

Console