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

              
                <h1>Simple Fixed Grid</h1>
<div class="container fixed">
  <h2>Columns</h2>
  <div class="box all-1"></div>
  <div class="box large-7 medium-4 small-2"></div>
  
  <div class="box large-2 medium-2 small-1"></div>
  <div class="box large-6 medium-3 small-2"></div>
  
  <div class="box large-3 medium-2 small-1"></div>
  <div class="box large-5 medium-3 small-2"></div>
  
  <div class="box large-4 medium-2 small-1"></div>
  <div class="box large-4 medium-3 small-2"></div>
  
  <div class="box large-5 medium-3 small-2"></div>
  <div class="box large-3 medium-2 small-1"></div>
  
  <div class="box large-6 medium-3 small-2"></div>
  <div class="box large-2 medium-2 small-1"></div>
  
  <div class="box large-7 medium-4 small-2"></div>
  <div class="box all-1"></div>
  
  <div class="box large-8 medium-5 small-3"></div>
</div>

<div class="container fixed">
  <h2>Offsets</h2>
  <div class="box all-1 large-offset-7 medium-offset-4 small-offset-2"></div>
  <div class="box all-2 large-offset-6 medium-offset-3 small-offset-1"></div>
  <div class="box all-3 large-offset-5 medium-offset-2"></div>
  <div class="box large-4 medium-4 small-3 large-offset-4 medium-offset-1"></div>
  <div class="box large-5 medium-5 small-3 large-offset-3"></div>
  <div class="box large-6 medium-5 small-3 large-offset-2"></div>
  <div class="box large-7 medium-5 small-3 large-offset-1"></div>
  <div class="box large-8 medium-5 small-3"></div>
</div>

<h1>Simple Fluid Grid</h1>
<div class="container fluid">
  <h2>Columns</h2>
  <div class="box large-1 medium-2 small-3">
    <div class="inner-box"></div>
  </div>
  <div class="box large-7 medium-6 small-5">
    <div class="inner-box"></div>
  </div>
  
  <div class="box large-2 medium-3 small-4">
    <div class="inner-box"></div>
  </div>
  <div class="box large-6 medium-5 small-4">
    <div class="inner-box"></div>
  </div>
  
  <div class="box large-3 medium-3 small-4">
    <div class="inner-box"></div>
  </div>
  <div class="box large-5 medium-5 small-4">
    <div class="inner-box"></div>
  </div>
  
  <div class="box all-4">
    <div class="inner-box"></div>
  </div>
  <div class="box all-4">
    <div class="inner-box"></div>
  </div>
  
  <div class="box large-5 medium-5 small-4">
    <div class="inner-box"></div>
  </div>
  <div class="box large-3 medium-3 small-4">
    <div class="inner-box"></div>
  </div>
  
  <div class="box large-6 medium-5 small-4">
    <div class="inner-box"></div>
  </div>
  <div class="box large-2 medium-3 small-4">
    <div class="inner-box"></div>
  </div>
  
  <div class="box large-7 medium-6 small-5">
    <div class="inner-box"></div>
  </div>
  <div class="box large-1 medium-2 small-3">
    <div class="inner-box"></div>
  </div>
  
  <div class="box all-8">
    <div class="inner-box"></div>
  </div>
</div>

<div class="container fluid">
  <h2>Offsets</h2>
  <div class="box large-1 medium-2 small-3 large-offset-7 medium-offset-6 small-offset-5">
    <div class="inner-box"></div>
  </div>
  <div class="box large-2 medium-3 small-4 large-offset-6 medium-offset-5 small-offset-4">
    <div class="inner-box"></div>
  </div>
  <div class="box large-3 medium-3 small-4 large-offset-5 medium-offset-5 small-offset-4">
    <div class="inner-box"></div>
  </div>
  <div class="box all-4 all-offset-4">
    <div class="inner-box"></div>
  </div>
  <div class="box large-5 medium-5 small-4 large-offset-3 medium-offset-3 small-offset-4">
    <div class="inner-box"></div>
  </div>
  <div class="box large-6 medium-5 small-4 large-offset-2 medium-offset-3 small-offset-4">
    <div class="inner-box"></div>
  </div>
  <div class="box large-7 medium-6 small-5 large-offset-1 medium-offset-2 small-offset-3">
    <div class="inner-box"></div>
  </div>
  <div class="box all-8">
    <div class="inner-box"></div>
  </div>
</div>
              
            
!

CSS

              
                @import "compass/css3";

////////////////////////
// User Configuration //
////////////////////////

$all: "all", "screen";
$large: "large", "screen and (min-width: 1024px)";
$medium: "medium", "screen and (min-width: 600px) and (max-width: 1023px)";
$small: "small", "screen and (max-width: 599px)";
$breakpoints: $all, $large, $medium, $small;

$grid-columns: 8;
$grid-unit: 100px;
$grid-gutter: 10px;

////////////
// Mixins //
////////////

// Calculates the grid's outer width:
@mixin grid-outer-width() {
  width: ($grid-unit * $grid-columns) + ($grid-gutter * $grid-columns);
}

// Calculates a fixed column's width:
@mixin grid-column-fixed-width($columns) {
  width: ($grid-unit * $columns) + ($grid-gutter * ($columns - 1));
}

// Calculates a fluid column's width:
@mixin grid-column-fluid-width($columns) {
  width: percentage($columns / $grid-columns);
}

// Generates a fixed or fluid grid based on the columns,
// unit width, gutter width, and breakpoints defined:
@mixin grid($type) {
  @each $breakpoint in $breakpoints {
    @media #{nth($breakpoint, 2)} {
      // Columns
      @for $i from 1 through $grid-columns {
        .#{nth($breakpoint, 1)}-#{$i} {
          // Fixed Grid
          @if $type == "fixed" {
            @include grid-column-fixed-width($i);
            margin: $grid-gutter / 2;
          // Fluid Grid
          } @else if $type == "fluid" {
            @include grid-column-fluid-width($i);
            padding: $grid-gutter / 2;
          }
        }
      }
      // Offsets
      @for $i from 1 through $grid-columns {
        .#{nth($breakpoint, 1)}-offset-#{$i} {
          // Fixed Grid
          @if $type == "fixed" {
            margin-left: (($grid-unit + $grid-gutter) * $i) + ($grid-gutter / 2);
          // Fluid Grid
          } @else if $type == "fluid" {
            margin-left: percentage($i / $grid-columns);
          }
        }
      }
    }
  }
}

/////////////////
// Demo Styles //
/////////////////

.fixed {
  @include grid("fixed");
}

.fluid {
  @include grid("fluid");
  
  .box {
    border: none;
    background: transparent;
    
    &:hover {
      border: none;
      background: transparent;
      &:after {
        top: 6px;
        left: 6px;
      }
    }  
  }
}

body { background: rgb(228, 239, 240); }

h1 {
  text-align: center;
  color: rgb(50, 113, 155);
}

h2 {
  margin-bottom: 5px;
  color: rgb(50, 113, 155);
}

.container {
  @include grid-outer-width;
  margin: 10px auto;
  overflow: hidden;
  
  &.fluid {
    width: 73%;
  }
  
  @media #{nth($medium, 2)} {
    width: 550px;
  }

  @media #{nth($small, 2)} {
    width: 330px;  
  }
}

.box {
  position: relative;
  
  box-sizing: border-box;
  float: left;
  height: 100px;
  padding: 30px;
  border: 1px solid rgb(168, 198, 218);
  background: rgb(195, 219, 226);
  text-align: center;
  
  &:hover {
    border: 1px solid darken(rgb(168, 198,218), 10%);
    background: darken(rgb(195, 219, 226), 10%);
    cursor: pointer;
    &:after {
      content: attr(class);
      position: absolute;
      top: 0;
      left: 0;
      padding: 3px;
      background: rgb(228, 239, 240);
      opacity: 0.7;
      font-size: 12px;
    }
  }
}

.inner-box {
  position: relative;
  
  width: 100%;
  height: 100%;
  
  border: 1px solid rgb(168, 198, 218);
  background: rgb(195, 219, 226);
  
  &:hover {
    border: 1px solid darken(rgb(168, 198,218), 10%);
    background: darken(rgb(195, 219, 226), 10%);
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console