123

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.

            
              <div class="header">
  <div class="col"></div>
  <div class="col"></div>
</div>

<div class="wrapper">
  <div class="aside"></div>
  <div class="main">
    
    <div class="block"></div>
    <div class="block"></div>
    <div class="block"></div>
    <div class="block"></div>
    
    <div class="block"></div>
    <div class="block"></div>
    <div class="block"></div>
    <div class="block"></div>
    
    <div class="block"></div>
    <div class="block"></div>
    <div class="block"></div>
    <div class="block"></div>
    
  </div>
  <div class="sidebar"></div>
</div>

<div class="footer">
  <div class="col"></div>
  <div class="col"></div>
  <div class="col"></div>
</div>
            
          
!
            
              @import "compass/css3";

// Here is a grid system
// Relying on `calc()` (http://caniuse.com/#search=calc)
// and advanced CSS selectors (http://caniuse.com/#feat=css-sel3)
// Expect it to work on IE9+, Android 4.4+ and any other browsers


// Applying a clean box-model to all elements
* {
  box-sizing: border-box;
}

// Grid configuration
$grid-gutter     :  10px !default;
$grid-columns    :    12 !default;
$grid-children   : 'div' !default;
$grid-breakpoint :  48em !default;

// Creating placeholders
// For all columns of the grid
@for $i from 1 through $grid-columns {
  %grid-col-#{$i} {
    $multiplier: $i / $grid-columns;
    width: calc(100% * #{$multiplier} - #{$grid-gutter} * (1 - #{$multiplier}));
  }
}

// Parent, grid wrapper
%grid-parent {
  overflow: hidden;
}
  
// Children, grid columns
%grid-child {
  float: left;
  margin-right: $grid-gutter;
}

// Last child from grid
%grid-last-child {
  margin-right: 0;
}

// Instanciate placeholder inside a media query
// So it can be extended from within the same media query elsewhere in the CSS
// This aims at reducing CSS output by merging all those rules
@media (max-width: $grid-breakpoint) {
  %grid-fallback > #{$grid-children} {
    width: 100% !important;
    float: none;
    margin-right: 0;
  }
}


// Mixin to be called on parent
// Will use :nth-of-type selectors to define columns width
// e.g. grid(1, 2, 4, 5) will result in
// | 1 |  2   |     4      |       5       |
@mixin grid($cols...) { 
  // Clearing inner floats
  @extend %grid-parent;

  // Direct children (default 'div')
  > #{$grid-children} { 
    @extend %grid-child;
    
    // Setting columns
    @for $i from 1 through length($cols) {
      &:nth-of-type(#{$i}n) {
        @extend %grid-col-#{nth($cols, $i)};
      }
    }
      
    // Cancelling right margin on last element from each row
    &:nth-of-type(#{length($cols)}n) {
      @extend %grid-last-child;
    }
  }

  // Small screens
  @media (max-width: $grid-breakpoint) {
    @extend %grid-fallback;
  }
}

.main {
  padding: $grid-gutter;
}

// Including the mixin
// First col: 2 on 12
// Second col: 8 on 12
// Last col: 2 on 12
.wrapper {
  @include grid(2, 8, 2);
}

// Including the mixin for inner grid
// Specifying the pattern for a single row
// Which will be repeated for next rows
.main {
  @include grid(2, 4, 2, 4); 
  padding-bottom: 0;
}

// Including the mixin for inner grid
// Specifying the pattern for a single row
// Which will be reopeat for next rows
.footer {
  @include grid(4, 4, 4);
}

.header {
  @include grid(2, 10);
}

.footer,
.header {
  margin: $grid-gutter 0;
}
 
.sidebar, .aside {
  min-height: calc(5em * 3 + 4 * #{$grid-gutter}); // Strictly relative to demo 
} 

.block {
  min-height: 5em;
  margin-bottom: $grid-gutter; 
}


.col {
  min-height: 2em;
}

body {
  padding: 0 $grid-gutter;
}


// Colors
.header,
.footer {
  background: #7f8c8d;  
}

.sidebar,
.aside {
  background: #1abc9c;
}

.main {
  background: #3498db;
}

.block {
  background: #34495e;
}  

.col {
  background: darken(#7f8c8d, 20%);
}
            
          
!
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.

Console