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-pack</h1>
<hr />
<p>The pack object simply causes any number of elements pack up horizontally to automatically fill an equal, fluid width of their parent.</p>
<p></p>

<div class="o-pack o-pack--demo">
  <div class="o-pack__item"></div>
  <div class="o-pack__item"></div>
  <div class="o-pack__item"></div>
</div>

<div class="o-pack o-pack--demo">
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/320x240/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/640x480/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/800x600/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/1024x768/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/1280x960/">
  </div>
</div>

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

<p>None (default)</p>
<div class="o-pack o-pack--space-none o-pack--demo">
  <div class="o-pack__item"></div>
  <div class="o-pack__item"></div>
  <div class="o-pack__item"></div>
</div>

<p>Tiny</p>
<div class="o-pack o-pack--space-tiny o-pack--demo">
  <div class="o-pack__item"></div>
  <div class="o-pack__item"></div>
  <div class="o-pack__item"></div>
</div>

<p>Small</p>
<div class="o-pack o-pack--space-small o-pack--demo">
  <div class="o-pack__item"></div>
  <div class="o-pack__item"></div>
  <div class="o-pack__item"></div>
</div>

<p>Medium</p>
<div class="o-pack o-pack--space-medium o-pack--demo">
  <div class="o-pack__item"></div>
  <div class="o-pack__item"></div>
  <div class="o-pack__item"></div>
</div>

<h3>Auto width modifier</h3>
<hr />

<div class="o-pack o-pack--auto o-pack--demo">
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/320x240/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/640x480/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/800x600/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/1024x768/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/1280x960/">
  </div>
</div>

<h3>Vertical alignment modifier</h3>
<hr />

<p>Middle</p>
<div class="o-pack o-pack--middle o-pack--auto o-pack--demo">
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/320x240/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/640x480/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/800x600/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/1024x768/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/1280x960/">
  </div>
</div>

<p>Bottom</p>
<div class="o-pack o-pack--bottom o-pack--auto o-pack--demo">
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/320x240/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/640x480/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/800x600/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/1024x768/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/1280x960/">
  </div>
</div>

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

<div class="o-pack o-pack--reverse o-pack--demo">
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/320x240/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/640x480/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/800x600/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/1024x768/">
  </div>
  <div class="o-pack__item">
    <img src="http://fakeimg.pl/1280x960/">
  </div>
</div>

              
            
!

CSS

              
                /* -------------------------------------------------------------------------
 * SETTINGS AND GENERIC FOR DEMO
 */
$s-core-font-size:            16px !default;
html {box-sizing: border-box;}
* {
  &, &:before, &:after { box-sizing: inherit;}
}

body {
  padding: 40px;
  line-height: 1.618;
}
img {
  max-width: 100%;
  vertical-align: middle;
}
p {
  margin: 0;
}

/* -------------------------------------------------------------------------
 * 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;

/* -------------------------------------------------------------------------
 * PACK
 *
 * The pack object simply causes any number of elements pack up horizontally to
 * automatically fill an equal, fluid width of their parent.
 *
 */

$o-pack-spaces:                         map_remove($s-spaces, large, huge) !default;
$o-pack-default-space:                  none !default;
$o-pack-include-modifiers-space:        true !default;
$o-pack-include-modifiers-reverse:      true !default;
$o-pack-include-modifiers-alignment-v:  true !default;
$o-pack-include-modifiers-width-auto:   true !default;


/*
 * [1]. Fill all available space.
 * [2]. Remove any leftover styling from lists.
 * [3]. Cause children to be automatically equally sized.
 *
 */

.o-pack {
  width: 100%; /* [1] */
  margin-left: 0; /* [2] */
  display: table;
  table-layout: fixed; /* [3] */
  border-spacing: map-get($o-pack-spaces, $o-pack-default-space);
}

/**
 * [1]. Cause children to adopt table-like structure.
 * [2]. Default item alignment is with the tops of each other.
 */

.o-pack__item {
  display: table-cell; /* [1] */
  vertical-align: top; /* [2] */
}


// Space modifiers
// --------------------------------------------------

@mixin o-pack--space($space-name: none, $space-value: 0) {
  .o-pack--space-#{$space-name} {
    border-spacing: $space-value;
  }
}

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


// Auto-Width modifier
// --------------------------------------------------

@if ($o-pack-include-modifiers-width-auto) {
  .o-pack--auto {
    table-layout: auto;
  }
}


// Vertical alignment modifiers
// --------------------------------------------------

@if ($o-pack-include-modifiers-alignment-v) {
  .o-pack--middle > .o-pack__item {
    vertical-align: middle;
  }
  .o-pack--bottom > .o-pack__item {
    vertical-align: bottom;
  }
}


// Reverse modifier
// --------------------------------------------------

@if ($o-pack-include-modifiers-reverse) {
  .o-pack--reverse {
    direction: rtl;
    > .o-pack__item {
      direction: ltr;
    }
  }
}


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

.o-pack--demo {
  margin-bottom: $s-space-large;
  margin-top: $s-space;
  outline: grey dashed 2px;
  &:before {
    display: table-header-group;
    content: "Pack object";
    font-size: .6rem;
    color: #888;
    text-transform: uppercase;
  }
  .o-pack__item {
    outline: red dashed 2px;
    &: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;
        display: block;
      }
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console