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

              
                .wrap
  .grid
    .grid__col.grid__col--1-of-2
    .grid__col.grid__col--1-of-2
  
    .grid__col.grid__col--1-of-3
    .grid__col.grid__col--2-of-3
    .grid__col.grid__col--3-of-3
    
    - (1..3).each do |i|
      %div{:class => "grid__col grid__col--1-of-3"}
    
    .grid__col.grid__col--1-of-4
    .grid__col.grid__col--1-of-4
    .grid__col.grid__col--2-of-4
    .grid__col.grid__col--3-of-4
    .grid__col.grid__col--1-of-4
    
    - (1..4).each do |i|
      %div{:class => "grid__col grid__col--1-of-4"}
    
    .grid__col.grid__col--1-of-5
    .grid__col.grid__col--1-of-5
    .grid__col.grid__col--2-of-5
    .grid__col.grid__col--1-of-5
    .grid__col.grid__col--3-of-5
    .grid__col.grid__col--2-of-5
    
    .grid__col.grid__col--3-of-5.grid__col--centered        
    
    - (1..5).each do |i|
      %div{:class => "grid__col grid__col--1-of-5"}
      
    .grid__col.grid__col--1-of-6
    .grid__col.grid__col--2-of-6
    .grid__col.grid__col--3-of-6
    
    .grid__col.grid__col--4-of-6
    .grid__col.grid__col--2-of-6
    
    - (1..6).each do |i|
      %div{:class => "grid__col grid__col--1-of-6"}
    
    .grid__col.grid__col--1-of-8
    .grid__col.grid__col--2-of-8
    .grid__col.grid__col--3-of-8
    .grid__col.grid__col--2-of-8
    
    .grid__col.grid__col--5-of-8
    .grid__col.grid__col--3-of-8
    
    - (1..8).each do |i|
      %div{:class => "grid__col grid__col--1-of-8"}
    
    .grid__col.grid__col--1-of-12
    .grid__col.grid__col--2-of-12
    .grid__col.grid__col--3-of-12
    .grid__col.grid__col--4-of-12
    .grid__col.grid__col--2-of-12
    
    .grid__col.grid__col--5-of-12
    .grid__col.grid__col--7-of-12
    
    .grid__col.grid__col--6-of-12
    .grid__col.grid__col--6-of-12
    
    .grid__col.grid__col--12-of-12
    
    - (1..12).each do |i|
      %div{:class => "grid__col grid__col--1-of-12"}
      
    .grid__col.grid__col--push-3-of-12.grid__col--6-of-12
    .grid__col.grid__col--3-of-12
    
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

/*---------------------------------------------------*/

// Namespaces
// This stops me from being overzealous with enforcing classes
$grid-namespace: "grid";
$grid-column-namespace: "grid__col";

// $col-groups are the column groups you want
// For example, $col-groups: (3, 4, 5) will output:
// .grid__col--n-of-3, .grid__col--n-of-4, [...]
$col-groups: (2, 3, 4, 5, 6, 8, 12);

// Gutter width
$gutter-width: 20px;

.#{$grid-namespace} {
  list-style: none;
  margin-left: -$gutter-width;

  > %span-all       { width: percentage(1/1); }

  > %one-half       { width: percentage(1/2); }

  > %one-third      { width: percentage(1/3); }
  > %two-thirds     { width: percentage(2/3); }

  > %one-quarter    { width: percentage(1/4); }
  > %two-quarters   { width: percentage(2/4); }
  > %three-quarters { width: percentage(3/4); }

  > %push-span-all       { margin-left: percentage(1/1); }

  > %push-one-half       { margin-left: percentage(1/2); }

  > %push-one-third      { margin-left: percentage(1/3); }
  > %push-two-thirds     { margin-left: percentage(2/3); }

  > %push-one-quarter    { margin-left: percentage(1/4); }
  > %push-two-quarters   { margin-left: percentage(2/4); }
  > %push-three-quarters { margin-left: percentage(3/4); }

  > %pull-span-all       { margin-left: -(percentage(1/1)); }

  > %pull-one-half       { margin-left: -(percentage(1/2)); }

  > %pull-one-third      { margin-left: -(percentage(1/3)); }
  > %pull-two-thirds     { margin-left: -(percentage(2/3)); }

  > %pull-one-quarter    { margin-left: -(percentage(1/4)); }
  > %pull-two-quarters   { margin-left: -(percentage(2/4)); }
  > %pull-three-quarters { margin-left: -(percentage(3/4)); }

  // For each of our column groups...
  @each $group in $col-groups {

    // For each column width from 1 to the column group...
    @for $i from 1 through $group {
      > .#{$grid-column-namespace}--#{$i}-of-#{$group} {

        @if percentage($i/$group) == percentage(1/1) {
          @extend %span-all;
        } @else if percentage($i/$group) == percentage(1/2) {
          @extend %one-half;
        } @else if percentage($i/$group) == percentage(1/3) {
          @extend %one-third;
        } @else if percentage($i/$group) == percentage(2/3) {
          @extend %two-thirds;
        } @else if percentage($i/$group) == percentage(1/4) {
          @extend %one-quarter;
        } @else if percentage($i/$group) == percentage(2/4) {
          @extend %two-quarters;
        } @else if percentage($i/$group) == percentage(3/4) {
          @extend %three-quarters;
        } @else {

          width: percentage($i/$group);

        }
      }

      > .#{$grid-column-namespace}--push-#{$i}-of-#{$group} {

        @if percentage($i/$group) == percentage(1/1) {
          @extend %push-span-all;
        } @else if percentage($i/$group) == percentage(1/2) {
          @extend %push-one-half;
        } @else if percentage($i/$group) == percentage(1/3) {
          @extend %push-one-third;
        } @else if percentage($i/$group) == percentage(2/3) {
          @extend %push-two-thirds;
        } @else if percentage($i/$group) == percentage(1/4) {
          @extend %push-one-quarter;
        } @else if percentage($i/$group) == percentage(2/4) {
          @extend %push-two-quarters;
        } @else if percentage($i/$group) == percentage(3/4) {
          @extend %push-three-quarters;
        } @else {

          margin-left: percentage($i/$group);

        }
      }

      > .#{$grid-column-namespace}--pull-#{$i}-of-#{$group} {

        @if percentage($i/$group) == percentage(1/1) {
          @extend %pull-span-all;
        } @else if percentage($i/$group) == percentage(1/2) {
          @extend %pull-one-half;
        } @else if percentage($i/$group) == percentage(1/3) {
          @extend %pull-one-third;
        } @else if percentage($i/$group) == percentage(2/3) {
          @extend %pull-two-thirds;
        } @else if percentage($i/$group) == percentage(1/4) {
          @extend %pull-one-quarter;
        } @else if percentage($i/$group) == percentage(2/4) {
          @extend %pull-two-quarters;
        } @else if percentage($i/$group) == percentage(3/4) {
          @extend %pull-three-quarters;
        } @else {

          margin-left: -(percentage($i/$group));

        }
      }
    } // end @for

  } // end @each

  // All direct descendents of .grid get treated the same way.
  // This might be overkill for some, but it’s a time-saver for me.
  > *, .#{$grid-column-namespace} {
    box-sizing: border-box;
    display: inline-block;
    margin-right: -.25em;
    min-height: 1px;
    padding-left: $gutter-width;
    vertical-align: top;

    @media screen and (max-width: 700px) {
      display: block;
      margin-left: 0;
      margin-right: 0;
      padding-left: 0;
      width: auto;
    }
  }

  .#{$grid-column-namespace}--centered {
    display: block;
    margin-left: auto;
    margin-right: auto;
  }


  @media screen and (max-width: 700px) {
    margin-left: 0;
    width: auto;
  }


  .#{$grid-column-namespace}--d-first {
    float: left;
  }

  .#{$grid-column-namespace}--d-last {
    float: right;
  }

  &--no-gutter {
    margin-left: 0;
    width: 100%;

    > * {
      padding-left: 0;
    }

    .#{$grid-column-namespace}--span-all, & > .span-all {
      margin-left: 0;
      width: 100%;
    }
  }

  // Align column to the bottom. Useful for aligned promo images.
  .#{$grid-column-namespace}--align-bottom {
    vertical-align: bottom;
  }

}

/*---------------------------------------------------*/

// Styles exclusive to demo

@each $i in $col-groups {
  [class*="-of-#{$i}"] {
    height: 40px;
    margin-bottom: 20px;
    
    background-clip: content-box;
    background-color: adjust-hue(hsla(($i*12), 50, 50, .5), 120deg);
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console