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.

            
              <p class="all">EVERYTHING</p>
<p class="no-margin">NO BOTTOM MARGIN</p>
<p class="no-line-height">NO LINE HEIGHT</p>
<p class="define-line-height">CUSTOM LINE HEIGHT</p>
<p class="define-margin-bottom">CUSTOM BOTTOM MARGIN</p>
<p class="define-all">CUSTOM BOTTOM MARGIN, CUSTOM LINE HEIGHT</p>

<a class="all" href="http://alwaystwisted.com/post.php?s=2013-12-30-not-your-average-vertical-rhythm-sass-mixin">I wrote this up in a blog post</a>
            
          
!
            
              @import "compass/css3";

/* 

  Vertical Rhythm Mixin

    This mixin is to help create a typograhpical baseline grid but also to allow for specifying different line heights or bottom margins if you need to.

    In this mixin you can specifiy the font size in PX and it will calculate the REM based on your $doc-font-size & $doc-line-height variables. 

      @include font-size(24);

    It will also create a bottom margin based on the $doc-font-size & $doc-line-height variables unless you specify that it shouldn't have one -

      @include font-size(24, no);

    Or if you want to specify a different bottom margin to be generated -

      @include font-size(24,32);

    This mixin also generates a pixel-less line height by default unless you specify that you either don't want one where I'd suggest declaring 1 within the mixin -

      @include font-size(24, yes, 1);

    There's also the option to specify a different line-height for it to generate to, where you would specify the line-height in (effectively) it's pixel value -

      @include font-size(24, yes, 40);

*/

// this is the default font-size you want for the project
/////////////////////////////////////////////////////////

  $doc-font-size: 16;

// this is the default line-height you want for the project
///////////////////////////////////////////////////////////

  $doc-line-height: 24;

// the magic mixin
//////////////////

  @mixin font-size($size, $margin: yes, $line-height: $doc-line-height) {
    
      // generates the font-size in REMs with a PX fallback
      font-size: 0px + $size;
      font-size: 0rem + $size / $doc-font-size;
    
      // line-height functions
      ////////////////////////
    
      // if you a line-height is specified in the mixin
      @if $line-height != $doc-line-height and $line-height != 1 {
        line-height: ceil($size / $line-height) * ($line-height / $size);
      }
      
      // if $line-height == 1
      // because, typing 1 is quicker than 16
      @else if $line-height == 1 {
        line-height: 1;
      }
    
      // normal $line-height
      // if the line-height is left.
      @else {
        line-height: ceil($size / $doc-line-height) * ($doc-line-height / $size);
      }
    
      // margin-bottom functions
      //////////////////////////
    
      // if no is bottom margin is required
      @if $margin == no {
        margin-bottom: 0;  
      }  
      
      // if a specific bottom margin is required
      @else if $margin != yes and $margin != no {
        margin-bottom: 0px + $margin;
        margin-bottom: 0rem + ($margin / $doc-font-size);  
      }
    
      // if you're keeping the vertical rhythm with the margin
      @else {
        margin-bottom: 0px + $doc-line-height;
        margin-bottom: 0rem + ($doc-line-height / $doc-font-size);  
      }
  }


.all { @include font-size(14); }
.no-margin { @include font-size(16, no); }
.no-line-height { @include font-size(16, yes, 1); }
.define-line-height { @include font-size(16, yes, 48); }
.define-margin-bottom { @include font-size(16, 48); }
.define-all { @include font-size(16, 48, 48); }
            
          
!
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