cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

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.

            
              <div class="contain">
  <div id="ponyo">
    <h1>@include centerEl;</h1>
    <p>With this SCSS mixin you'll be able to horizontally AND vertically center blocks of text dynamically, with ease</p>
  </div>
</div>

<div class="contain">
  <div id="billmurray">
    <p>To use it, just <code>@include centerEl</code></p>
    <p>You can set some properties through parameters too, like the <code>left</code> position, <code>width</code> and <code>text-align</code>.</p>
    <p><small>Defaults: <code>$left: 50%, $width: 50%, $align: center</code></small></p>
  </div>
</div>

<div class="contain">
  <div id="jeffgolenski">
    <p>But you don't have to horizontally align if you don't want to. Just include the mixin like this...</p>
    <code>@include centerEl($left: 95%, $align: left);</code>
  </div>
</div>

<div class="contain">
  <div id="poppop">
    <p>Or you can include the mixin like this...</p>
    <code>@include centerEl($left: 5%, $width: auto, $align: left);</code>
  </div>
</div>

<div class="contain">
  <div id="cred">
    <p>Forked and adapted from a <a href="http://jsfiddle.net/jeffgolenski/hchhT/13/" target="_blank">Fiddle</a> by <a href="https://twitter.com/jeffgolenski" target="_blank">@jeffgolenski</a></p>
  </div>
</div>
            
          
!
            
              $base: #94c6fd;

@function dynamicColor ($color) {
  @if ( lightness($color) < 50% ) {
    @return #eee;
  } @else {
    @return #111;
  }
}

@mixin centerEl ( $left: 50%, $width: 50%, $align: center ) {
  position: absolute;
  top: 50%;
  left: $left;
  -ms-transform: translate($left * -1,-50%);
  -webkit-transform: translate($left * -1,-50%);
  transform: translate($left * -1,-50%);
  width: $width;
  > * {
    display: block;
    padding: 0 10px;
    text-align: $align;
    width: 100%;
  }
}

:root {
  background: $base;
  padding: 3em;
  .contain {
    background: white;
    box-shadow: 0 2px 2px darken($base, 15%);
    color: #111;
    font-size: 1.3em;
    height: 300px; max-width: 1000px; width: 100%;
    margin: 0 auto;
    text-shadow: 0 1px 2px rgba(black, 0.4);
    position: relative;
    + .contain {
      margin-top: 3em;
    }
    a {
      color: dynamicColor($base);
    }
  }
}

#ponyo, #billmurray {
  @include centerEl;
}

#jeffgolenski {
  @include centerEl($left: 95%, $align: left);
}

#poppop {
  @include centerEl($left: 5%, $width: auto, $align: left);
}

#cred {
  @include centerEl($width: 80%)
}
            
          
!
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.
Loading ..................

Console