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-media</h1>
<hr />
<p>Place any image- and text-like content side-by-side.</p>
<p></p>

<div class="o-media o-media--demo">
  <div class="o-media__img"></div>
  <div class="o-media__body"></div>
</div>

<div class="o-media o-media--demo">
  <div class="o-media__img"></div>
  <div class="o-media__body">
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Numquam, reiciendis fugiat ut voluptate fugit quisquam modi maiores, perspiciatis quasi praesentium ab vel at repellat amet atque? Veniam, officia, sint. Deleniti!</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur sed, omnis ipsa exercitationem illo ut. Eos, porro voluptas unde velit totam aliquid iste molestias deleniti necessitatibus et quia, temporibus, ullam!</p>
  </div>
</div>

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

<p>None</p>
<div class="o-media o-media--space-none o-media--demo">
  <div class="o-media__img"></div>
  <div class="o-media__body"></div>
</div>

<p>Tiny</p>
<div class="o-media o-media--space-tiny o-media--demo">
  <div class="o-media__img"></div>
  <div class="o-media__body"></div>
</div>

<p>Small</p>
<div class="o-media o-media--space-small o-media--demo">
  <div class="o-media__img"></div>
  <div class="o-media__body"></div>
</div>

<p>Medium (default)</p>
<div class="o-media o-media--space-medium o-media--demo">
  <div class="o-media__img"></div>
  <div class="o-media__body"></div>
</div>

<h3>Reverse modifier</h3>
<hr />
<p>Reverse the direction</p>

<div class="o-media o-media--reverse o-media--demo">
  <div class="o-media__img"></div>
  <div class="o-media__body"></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;
}
p {
  margin-top: 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;


/* -------------------------------------------------------------------------
 * CLEARFIX
 *
 * Mixin to drop micro clearfix into a selector. Further reading:
 * http://www.cssmojo.com/the-very-latest-clearfix-reloaded/
 *
 */

@mixin t-clearfix() {
  &:after {
    content: "" !important;
    display: block !important;
    clear: both !important;
  }
}


/* -------------------------------------------------------------------------
 * MEDIA
 *
 * Place any image- and text-like content side-by-side, as per:
 * http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code
 *
 */

$o-media-spaces:                        map_remove($s-spaces, large, huge) !default;
$o-media-default-space:                 medium !default;
$o-media-include-modifiers-space:       true !default;
$o-media-include-modifiers-reverse:     true !default;


.o-media {
  @include t-clearfix;
  display: block;
}


.o-media__img {
  float: left;
  margin-right: map-get($o-media-spaces, $o-media-default-space);

  > img {
    display: block;
  }

}


.o-media__body {
  overflow: hidden;
  display: block;

  &,
  > :last-child {
    margin-bottom: 0;
  }

}


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

@mixin o-media--space($space-name: none, $space-value: 0) {
  .o-media--space-#{$space-name} {
    > .o-media__img {
      margin-right: $space-value;
    }
    @if ($o-media-include-modifiers-reverse) {
      &.o-media--reverse {
        > .o-media__img {
          margin-right: 0;
          margin-left:  $space-value;
        }
      }
    }
  }
}

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


// Reverse modifier
// --------------------------------------------------
@if ($o-media-include-modifiers-reverse) {

  .o-media--reverse {
    > .o-media__img {
      float: right;
      margin-right: 0;
      margin-left: map-get($o-media-spaces, $o-media-default-space);
    }
  }

}



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

.o-media--demo {
  position: relative;
  margin-bottom: $s-space-large;
  margin-top: $s-space;
  &:before {
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    outline: grey dashed 2px;
    background-color: #f8f8f8;
    content: "";
  }
  &:after {
    display: block;
    position: absolute;
    top: -1rem;
    right: $s-space-tiny;
    content: "Media object" !important;
    font-size: .6rem;
    color: #888;
    text-transform: uppercase;
  }
  
  .o-media__img,
  .o-media__body {
    position: relative;
    &:before {
      display: block;
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      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: "Media body";
        text-align: center;
        text-transform: uppercase;
        color: red;
        font-size: .6rem;
        background-color: #fff8f8;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
      }
    }
  }
  
  .o-media__body {
    &:empty {
      border: dashed 1px red;
    }
  }
  
  .o-media__img {
    &:empty {
      width: $s-space-huge;
      &:before {
        content: "Media img";
      }
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console