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. 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

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>o-layout</h1>
<hr />
<p>The layout object provides a column-style layout system. By default, a layout item gets full width.</p>
<p></p>

<div class="o-layout o-layout--demo">
  <div class="o-layout__item"></div>
  <div class="o-layout__item"></div>
</div>

<p>Layout items should be complemented with width utilities.</p>

<div class="o-layout o-layout--demo">
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
</div>

<p>Width utilities can also be defined for each available breakpoint</p>

<div class="o-layout o-layout--demo">
  <div class="o-layout__item u-1/1 u-1/1@xs u-1/2@sm u-1/4@md"></div>
  <div class="o-layout__item u-1/1 u-1/3@xs u-1/2@sm u-1/4@md"></div>
  <div class="o-layout__item u-1/2 u-1/3@xs u-1/2@sm u-1/4@md"></div>
  <div class="o-layout__item u-1/2 u-1/3@xs u-1/2@sm u-1/4@md"></div>
</div>

<h3>Space modifiers</h3>
<hr />

<p>None</p>
<div class="o-layout o-layout--space-none o-layout--demo">
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
</div>

<p>Tiny</p>
<div class="o-layout o-layout--space-tiny o-layout--demo">
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
</div>

<p>Small</p>
<div class="o-layout o-layout--space-small o-layout--demo">
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
</div>

<p>Medium (default)</p>
<div class="o-layout o-layout--space-medium o-layout--demo">
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
</div>

<h3>Reverse modifier</h3>
<hr />

<p>Reverse the order</p>
<div class="o-layout o-layout--reverse o-layout--demo">
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
</div>


<h3>Aligment vertical modifiers</h3>
<hr />

<p>Top (default)</p>
<div class="o-layout o-layout--demo">
  <div class="o-layout__item u-1/3">
  <p>Short content here</p>
  </div>
  <div class="o-layout__item u-1/3">
    <p>Long content starts with Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptas pariatur, facilis ea fugit eos ab mollitia.</p>
  </div>
  <div class="o-layout__item u-1/3">
    <p>I am the item number 3</p>
  </div>
</div>

<p>Middle</p>
<div class="o-layout o-layout--middle o-layout--demo">
  <div class="o-layout__item u-1/3">
  <p>Short content here</p>
  </div>
  <div class="o-layout__item u-1/3">
    <p>Long content starts with Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptas pariatur, facilis ea fugit eos ab mollitia.</p>
  </div>
  <div class="o-layout__item u-1/3">
    <p>I am the item number 3</p>
  </div>
</div>

<p>Bottom</p>
<div class="o-layout o-layout--bottom o-layout--demo">
  <div class="o-layout__item u-1/3">
  <p>Short content here</p>
  </div>
  <div class="o-layout__item u-1/3">
    <p>Long content starts with Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptas pariatur, facilis ea fugit eos ab mollitia.</p>
  </div>
  <div class="o-layout__item u-1/3">
    <p>I am the item number 3</p>
  </div>
</div>

<h3>Alignment horizontal modifiers</h3>
<hr />
<p>Determines the origin on filling with items when there's not enough to fullfill the object width</p>

<p>Left (default)</p>
<div class="o-layout o-layout--demo">
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
</div>

<p>Center</p>
<div class="o-layout o-layout--center o-layout--demo">
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
</div>

<p>Right</p>
<div class="o-layout o-layout--right o-layout--demo">
  <div class="o-layout__item u-1/3"></div>
  <div class="o-layout__item u-1/3"></div>
</div>

<h3>Auto width modifier</h3>
<hr />
<p>Cause layout items to take up a non-explicit amount of width.</p>
<div class="o-layout o-layout--auto o-layout--demo">
  <div class="o-layout__item">A short content</div>
  <div class="o-layout__item">This is a longer content, you know, Lorem ipsum dolor.</div>
</div>


<h3>Stretch modifier</h3>
<hr />
<p>Cause layout items to have the same width on the same row. CAUTION: this will not work on IE9 and lower, but should look like no modifier is applied.</p>
<div class="o-layout o-layout--stretch o-layout--demo">
  <div class="o-layout__item u-1/2@sm u-1/3@md">
    <p>A short content</p>
  </div>
  <div class="o-layout__item u-1/2@sm u-1/3@md">
    <p>Long content starts with Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptas pariatur, facilis ea fugit eos ab mollitia.</p>
  </div>
  <div class="o-layout__item u-1/3@md">
    <p>I am the item number 3</p>
  </div>
</div>
              
            
!

CSS

              
                /* -------------------------------------------------------------------------
 * LAYOUT OBJECT
 * Based on inuitcss objects (https://github.com/inuitcss/inuitcss)
 */

$s-core-font-size:            16px !default;

html {
  box-sizing: border-box;
}

* {
  &,
  &:before,
  &:after {
    box-sizing: inherit;
  }
}

body {
  padding: 40px;
  line-height: 1.618;
}

/* -------------------------------------------------------------------------
 * SPACES
 */

$s-core-space:                24px !default;

$s-space:                     round($s-core-space) !default;
$s-space-tiny:                round($s-space * 0.25) !default;
$s-space-small:               round($s-space * 0.5) !default;
$s-space-large:               round($s-space * 2) !default;
$s-space-huge:                round($s-space * 4) !default;


/* Spaces MAP
 */

$s-spaces: (
  "none":                     0,
  "tiny":                     $s-space-tiny,
  "small":                    $s-space-small,
  "medium":                   $s-space,
  "large":                    $s-space-large,
  "huge":                     $s-space-huge,
) !default;


/* -------------------------------------------------------------------------
 * LAYOUT
 * Grid-like layout system.
 */

$o-layout-enabled:                        true !default;

$o-layout-spaces:                         map_remove($s-spaces, "large", "huge") !default;
$o-layout-default-space:                  "medium" !default;
$o-layout-include-modifiers-space:        true !default;
$o-layout-include-modifiers-reverse:      true !default;
$o-layout-include-modifiers-alignment-v:  true !default;
$o-layout-include-modifiers-alignment-h:  true !default;
$o-layout-include-modifiers-width-auto:   true !default;
$o-layout-include-modifiers-stretch:      true !default;


// Default/mandatory classes
// --------------------------------------------------

@if ($o-layout-enabled) {
  /**
   * [1]. Allows us to use the layout object on any type of element.
   * [2]. We need to defensively reset any box-model properties.
   * [3]. Use the negative margin trick for multi-row grids:
   *      https://csswizardry.com/2011/08/building-better-grid-systems/
   */

  .o-layout {
    display: block; /* [1] */
    margin: 0; /* [2] */
    padding: 0; /* [2] */
    list-style: none; /* [1] */
    margin-left: -(map-get($o-layout-spaces, $o-layout-default-space)); /* [3] */
    font-size: 0;

  }


  /**
    * [1]. Required in order to combine fluid widths with fixed gutters.
    * [2]. Allows us to manipulate grids vertically, with text-level properties,
    *      etc.
    * [3]. Default item alignment is with the tops of each other, like most
    *      traditional grid/layout systems.
    * [4]. By default, all layout items are full-width (mobile first).
    * [5]. Gutters provided by left padding:
    *      https://csswizardry.com/2011/08/building-better-grid-systems/
    */

  .o-layout__item {
    box-sizing: border-box; /* [1] */
    display: inline-block; /* [2] */
    vertical-align: top; /* [3] */
    width: 100%; /* [4] */
    padding-left: map-get($o-layout-spaces, $o-layout-default-space); /* [5] */
    font-size: 1rem;
  }
}


// Space modifiers
// --------------------------------------------------
@mixin o-layout--space($space-name: none, $space-value: 0) {
  .o-layout--space-#{$space-name} {
    margin-left: -$space-value;
    > .o-layout__item {
      padding-left: $space-value;
    }
  }
}

@if ($o-layout-enabled and $o-layout-include-modifiers-space) {
  @each $space-name, $space-value in $o-layout-spaces {
    @if ($space-name != $o-layout-default-space) {
      @include o-layout--space($space-name, $space-value);
    }
  }
}


// Reverse modifier
// --------------------------------------------------
@if ($o-layout-enabled and $o-layout-include-modifiers-reverse) {

  // Reverse the rendered order of the grid system.
  .o-layout--reverse {
    direction: rtl;
    > .o-layout__item {
      direction: ltr;
      text-align: left;
    }
  }

}


// Vertical alignments
// --------------------------------------------------
@if ($o-layout-enabled and $o-layout-include-modifiers-alignment-v) {

  // Align all grid items to the middles of each other.
  .o-layout--middle {
    > .o-layout__item {
      vertical-align: middle;
    }
  }

  // Align all grid items to the bottoms of each other.
  .o-layout--bottom {
    > .o-layout__item {
      vertical-align: bottom;
    }
  }

}


// Horizontal alignments
// --------------------------------------------------
@if ($o-layout-enabled and $o-layout-include-modifiers-alignment-h) {

  // Fill up the layout system from the centre.
  .o-layout--center {
    text-align: center;
    > .o-layout__item {
      text-align: left;
    }
  }

  // Fill up the layout system from the right-hand side.
  .o-layout--right {
    text-align: right;
    > .o-layout__item {
      text-align: left;
    }
  }

  // Fill up the layout system from the left-hand side. This will likely only be
  // needed when using in conjunction with `.o-layout--reverse`.
  .o-layout--left {
    text-align: left;
    > .o-layout__item {
      text-align: left;
    }
  }

}


// Auto width modifier
// --------------------------------------------------
@if ($o-layout-enabled and $o-layout-include-modifiers-width-auto) {
  .o-layout--auto {
    > .o-layout__item {
      width: auto;
    }
  }
}


// Stretch modifier, stretch all grid items to have an equal-height
// --------------------------------------------------
@if ($o-layout-enabled and $o-layout-include-modifiers-stretch) {
  .o-layout--stretch {
    display: flex;
    flex-wrap: wrap;
    > .o-layout__item {
      display: flex;
    }
  }
}


// DEMO STYLES, only for demo propouses
// --------------------------------------------------

.o-layout--demo {
  position: relative;
  padding-top: $s-space-tiny;
  margin-bottom: $s-space-large;
  margin-top: $s-space;
  &:before {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: map-get($o-layout-spaces, $o-layout-default-space);
    right: 0;
    outline: grey dashed 2px;
    background-color: #f8f8f8;
    content: "";
    &.o-layout--space-tiny {
      left: $s-space-tiny;
    }
  }
  &.o-layout--space-none:before { left: 0;}
  &.o-layout--space-tiny:before { left: $s-space-tiny;}
  &.o-layout--space-small:before { left: $s-space-small;}
  &.o-layout--space-medium:before { left: $s-space;}
  &:after {
    display: block;
    position: absolute;
    top: -1rem;
    right: $s-space-tiny;
    content: "Layout object";
    font-size: .6rem;
    color: #888;
    text-transform: uppercase;
  }
  
  .o-layout__item {
    position: relative;
    margin-bottom: $s-space-tiny;
    > *:first-child {
      margin-top: 0;
    }
    &:before {
      display: block;
      position: absolute;
      top: 0;
      bottom: 0;
      left: map-get($o-layout-spaces, $o-layout-default-space);
      right: 0;
      outline: red dashed 2px;
      content: "";
    }
    &:empty {
      height: $s-space-huge;
      &:before {
        height: $s-space-huge;
        line-height: $s-space-huge;
        position: initial;
        content: "Layout item";
        text-align: center;
        text-transform: uppercase;
        color: red;
        font-size: .6rem;
        background-color: #fff8f8;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
      }
      &:nth-child(1):before { content: "Layout item 1";}
      &:nth-child(2):before { content: "Layout item 2";}
      &:nth-child(3):before { content: "Layout item 3";}
      &:nth-child(4):before { content: "Layout item 4";}
      &:nth-child(5):before { content: "Layout item 5";}
      &:nth-child(6):before { content: "Layout item 6";}
    }
  }
  &.o-layout--space-none:before,
  &.o-layout--space-none .o-layout__item:before { left: 0;}
  &.o-layout--space-tiny:before,
  &.o-layout--space-tiny .o-layout__item:before { left: $s-space-tiny;}
  &.o-layout--space-small:before,
  &.o-layout--space-small .o-layout__item:before { left: $s-space-small;}
  &.o-layout--space-medium:before,
  &.o-layout--space-medium .o-layout__item:before { left: $s-space;}
  
}

              
            
!

JS

              
                
              
            
!
999px

Console