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.

            
              <h2>2 columns</h2>
<div class="grid__col--2">
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
</div>

<h2>3 columns</h2>
<div class="grid__col--3">
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
</div>

<h2>4 columns</h2>
<div class="grid__col--4">
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
</div>

<h2>5 columns</h2>
<div class="grid__col--5">
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
</div>

<h2>6 columns</h2>
<div class="grid__col--6">
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
  <div class="col">
    <h3>H3 title</h3>
    <p>In platea urna, turpis in. Porttitor dictumst. Massa elementum habitasse eros cursus, nunc, natoque porta mus pellentesque, proin tortor, integer lundium ac mauris integer risus, a non elit nunc lundium, quis dapibus risus et! Porta, mus etiam, lorem
      nascetur nec urna penatibus placerat.</p>
  </div>
</div>
            
          
!
            
              // Base font size
$font-size-base: 16px;

// Global breakpoint variables (customisable)
$bp-xl: 1200px;
$bp-l: 960px;
$bp-m: 840px;
$bp-s: 640px;
$bp-xs: 480px;

// Min-width breakpoint
@mixin break-point-min($bp, $min-max: min-width) {
  $em: $bp/$font-size-base;
  @media(#{$min-max}: #{$em}em) { @content; }
}
// Max-width breakkpoint
@mixin break-point-max($bp, $min-max: max-width) {
  $em: $bp/$font-size-base;
  @media(#{$min-max}: #{$em}em) { @content; }
}

// Convert px to em function
@function pxToEm ($values, $elFontSize: $baseFontSize) {
  $list: ();

  @each $value in $values {
    @if ($value == 0 or $value == auto) {
      $list: append($list, $value);
    } @else {
      $emValue: ($value/$elFontSize)+em;
      $list: append($list, $emValue);
    }
  }
  @return $list;
}

// Styling of the h3 and p for the purpose of this demo
h3 {
  padding: pxToEm(0 15px, $font-size-base);
}
p {
  padding: pxToEm(0 20px, $font-size-base);
}

// Clearfix mixin
@mixin clearfix-me($method: $clearfix-method) {
  @if $method != overflow and $method != facebook and $method != micro and $method != stubborn {
    @warn "The clearfix method #{$method} is unkown";
    @extend %clearfix-micro;
  } @else {
    @extend %clearfix-#{$method};
  }

}

// Clearfix placeholder
%clearfix-micro {
  zoom: 1;
  &:before,
  &:after {
    content: " ";
    display: table;
  }
  &:after {
    clear: both;
  }
}


// GRID COLUMN CALCULATION
///////////////////////////

@function calculate-width ($col-span) {

    // Get the correct gutter calculation first ie...
    // -----------------------------------------------
    // 2 column = 1 gutter
    // 3 column = 2 gutters
    // etc...

    // Always one less gutter than the number of columns...
    $gutter-calc: ($col-span * $col-gutter) - $col-gutter; 

        // Now return the correctly calculated column width...
        @return (100% - $gutter-calc) / $col-span;
}


// GRID VARIABLES
//////////////////

$col-gutter: 1.6%; // If you increase the gutter size, the column widths will adjust accordingly.

$col-width-2: calculate-width(2);
$col-width-3: calculate-width(3);
$col-width-4: calculate-width(4);
$col-width-5: calculate-width(5);
$col-width-6: calculate-width(6);


// GRID MIXINS
///////////////

// Using a mixin instead, as a placeholder @extend call can't be used within a @media call

// Set / reset the columns
@mixin col-reset ($col-clear: none, $col-gutter-set: $col-gutter) {
    clear: $col-clear;
    margin-left: $col-gutter-set;
}

// Clear the first column (in each row) for each grid layout
@mixin col-clear ($col-clear: left, $col-gutter-remove: 0) {
    clear: $col-clear;
    margin-left: $col-gutter-remove;
}

// GRID IMPLEMENTATION
///////////////////////

// Base grid styles
/////////////////////////////////
[class^="grid__"],
[class*=" grid__"] {
  @include clearfix-me(micro);
  list-style: none; // In case a list is used
  padding: 0;
  margin: 0;

  .col {
    background-color: #000; // Demonstration purposes
    color: #fff; // Demonstration purposes
    float: left;
    margin: 0 0 pxToEm(15px, $font-size-base) $col-gutter;
    transition: all 0.2s linear;

        // Makes sure no gutter on single column layout (linear)
        @include break-point-max($bp-xs) {
            margin-left: 0;
        }

    // Remove margin-bottom from nested grid column
    .col {
        margin-bottom: 0;
    }

  }
}
/////////////////////////////////


// Grids with 2-6 columns share these rules
// More can be added eg. ".grid__col--7" etc.
.grid__col--2,
.grid__col--3,
.grid__col--4,
.grid__col--5,
.grid__col--6 {
    > .col {
        @include break-point-min($bp-xs) {

            width: $col-width-2;
            
            &:nth-child(n) {
                @include col-reset;
            }
            &:nth-child(2n+1) {
                @include col-clear;
            }
        }
    }
}

// Grids with 3-6 columns share these rules
.grid__col--3,
.grid__col--4,
.grid__col--5,
.grid__col--6 {
    > .col {
        @include break-point-min($bp-s) {

            width: $col-width-3;

            &:nth-child(n) {
                @include col-reset;
            }
            &:nth-child(3n+1), {
                @include col-clear;
            }
        }
    }
}

// Grids with 4-6 columns share these rules
.grid__col--4,
.grid__col--5,
.grid__col--6 {
    > .col {
        @include break-point-min($bp-m) {

            width: $col-width-4;

            &:nth-child(n) {
                @include col-reset;
            }
            &:nth-child(4n+1) {
                @include col-clear;
            }
        }
    }
}

// Grids with 5-6 columns share these rules
.grid__col--5,
.grid__col--6 {
    > .col {
        @include break-point-min($bp-l) {

            width: $col-width-5;

            &:nth-child(n) {
                @include col-reset;
            }
            &:nth-child(5n+1) {
                @include col-clear;
            }
        }
    }
}

// Grids with 6 columns
.grid__col--6 {
    > .col {
        @include break-point-min($bp-xl) {

            width: $col-width-6;

            &:nth-child(n) {
                @include col-reset;
            }
            &:nth-child(6n+1) {
                @include col-clear;
            }
        }
    }
}

// And so on......


/////////////////////////////////////////////////////////////
            
          
!
            
              // Nothing here at the moment.

// May extend the grid to handle equal heights content using flexbox with a flexbox polyfill for legacy browsers.
            
          
!
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