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

              
                <h2>H2 heading ($h2-font-sizes map)</h2>
<p class="large">Large paragraph text ($large-font-sizes map)</p>
<p class="small">Small paragraph text ($small-font-sizes map)</p>
              
            
!

CSS

              
                // These maps document our font maps based on breakpoint. Values labeled "small" will be applied when the browser is smaller than 800px wide. The "name" is used to name our CSS custom properties programmatically later.

// Each breakpoint's font values are a small map: the first value is the font-size, and the 2nd (if provided) is the line-height. If no line-height value is present at a breakpoint, then the line-height doesn't get overridden at that breakpoint.

$h2-font-sizes: (
    name: h2,
    default : (3rem, 1.1),
    small : (2.5rem)
);

$large-font-sizes: (
    name: large,
    default: (1.5rem, 1.4),
    small: (1.25rem)
);

$small-font-sizes: (
    name: small,
    default : (1rem, 1.4),
    small : (0.875rem)
);

// This list just makes it easier to iterate through each typography style below.
$_all-font-size-maps: ($h2-font-sizes, $large-font-sizes, $small-font-sizes);

// The code below takes these maps and spits out CSS custom properties with the "name" and the responsive values given.
:root {
  // This statement sets the default font-sizes and line-heights as CSS custom properties.
    @each $_font-size in $_all-font-size-maps {
        $_font-sizes: map-get($_font-size, default);
        $_font-name: map-get($_font-size, name);
        --#{$_font-name}-size: #{nth($_font-sizes, 1)};
        --#{$_font-name}-height: #{nth($_font-sizes, 2)};
    }

  // Here, the font-size and line-height (if given) are overridden at the smaller breakpoint. On a real site, the breakpoint values will come from another map for consistency across the project. For this example, I'm just using 800px as the breakpoint.
  @media (max-width: 800px) {
        @each $_font-size in $_all-font-size-maps {
            $_font-sizes: map-get($_font-size, small);
            $_font-name: map-get($_font-size, name);
            --#{$_font-name}-size: #{nth($_font-sizes, 1)};

            @if(length($_font-sizes) > 1) {
                --#{$_font-name}-height: #{nth($_font-sizes, 2)};
            }
        }
    }
}

// This mixin takes the complicated stuff above and applies it, so that we have an easy way to use our documented font maps in code. It sets the default font-size and line-height as the fallback, and then uses CSS custom property values for progressive enhancement.
@mixin font-size($font-map) {
    $_default-sizes: map-get($font-map, default);
    $_font-name: map-get($font-map, name);
    font-size: nth($_default-sizes, 1);
    line-height: nth($_default-sizes, 2);
    font-size: var(--#{$_font-name}-size);
    line-height: var(--#{$_font-name}-height);
}

// Now we can access our font sizes and line heights by utilizing this mixin and the map we want to use.
h2 {
  @include font-size($h2-font-sizes);
}

.large {
  @include font-size($large-font-sizes);
}

.small {
  @include font-size($small-font-sizes);
}

//
//
//
// Additional cleanup styles
body {
  font-family: 'Roboto', sans-serif;
  margin: 2rem;
  font-weight: 300;
}

* + * {
  margin-top: 1em;
}
              
            
!

JS

              
                
              
            
!
999px

Console