Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


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


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.


Auto Save

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.


                <h1>Adjust window size to see element styles</h1>

<p class="font-size">Evenly distributes font size between 400px and 1400px-wide windows.</p>
+spread(font-size, 16px, 25px)</pre>

<p class="font-size-eased">Setting easing for a property affects how quickly it changes with window size.</p>
+spread(font-size, 16px, 25px, $ease: out-quint)</pre>

<p class="font-size-two-sizes">By using multiple <code>$dimension-max/min</code>s, you can create different spread ranges.</p>
+spread(font-size, 16px, 25px, $dimension-max: 799px, $ease: out-quint)
+spread(font-size, 40px, 25px, $dimension-min: 800px, $ease: out-quint, $default-to-min: false)</pre>

<p class="font-size-no-min">By default, it uses your <code>$property-min</code> as the property to use below <code>$dimension-min</code>. But you can change this:</p>
+spread(font-size, 16px, 25px, $default-to-min: false)</pre>

<p class="font-size-high-precision">You can change the precision setting for more queries/values.</p>
+spread(font-size, 16px, 25px, $precision: 5)</pre>

<p class="percent-width">It works with percent values...</p>
+spread(width, 90%, 30%)</pre>

<p class="negative-margin">...and negative values.</p>
+spread(margin-left, 0, -50px)</pre>

<p class="height">It works with window height...</p>
+spread(height, 30px, 100px, min-height)</pre>

<p class="padding">...and you can mix height and width for a smart padding effect.</p>
+spread(padding-bottom, 5px, 50px, min-height)
+spread(padding-left, 5px, 50px)
+spread(padding-right, 5px, 50px)
+spread(padding-top, 5px, 50px, min-height)</pre>

<p class="max-width">If you're not building mobile-first, you can use <code>max-</code> media queries instead.</p>
+spread(font-size, 16px, 25px, max-width)</pre>



                // strip-units required by spread mixin
@function strip-units($number)
  @return $number / ($number * 0 + 1)

// pow and sqrt required by ease function
// adapted from
@function pow($base, $exponent)
  $value: $base
  @if $exponent > 1
    @for $i from 2 through $exponent
      $value: $value * $base
  @if $exponent < 1
    @for $i from 0 through -$exponent
      $value: $value / $base
  @return $value

@function sqrt($number)
  $root: 4
  @for $i from 1 through 50
    $root: $root - (pow($root, 2) - $number) / (2 * $root)
  @return $root

// adapted from
@function ease($iteration, $start-value, $change, $total-iterations, $ease)
  $progress: $iteration / $total-iterations

  // value increases evenly
  @if $ease == linear
    @return $change * $progress + $start-value

  // value increases on a curve, accelerating
  @if $ease == in-quad
    @return $change * $progress * $progress + $start-value

  // value increases on a curve, decelerating
  @if $ease == out-quad
    @return -$change * $progress * ($progress - 2) + $start-value

  // value accelerates sharply
  @if $ease == in-cubic
    @return $change * pow($progress, 3) + $start-value

  // value decelerates sharply
  @if $ease == out-cubic
    @return $change * (pow($progress - 1, 3) + 1) + $start-value

  // value accelerates more sharply
  @if $ease == in-quart
    @return $change * pow($progress, 4) + $start-value

  // value decelerates more sharply
  @if $ease == out-quart
    @return -$change * (pow($progress - 1, 4) - 1) + $start-value

  // value accelerates very sharply
  @if $ease == in-quint
    @return $change * pow($progress, 5) + $start-value

  // value decelerates very sharply
  @if $ease == out-quint
    @return $change * (pow($progress - 1, 5) + 1) + $start-value

// spreads a property value from min to max across media queries
//   $property:      CSS property to set
//   $property-min:  min value of the property
//   $property-max:  max value of the property
//   $dimension:     media query dimension - either min-width or min-height
//   $dimension-min: first media query of the chosen dimension
//   $dimension-max: final media query of the chosen dimension
//   $default-value: true/false (defaults to true).
//                   Should a default value (min for min-width/height,
//                   max for max-width/height) be included outside the query?
//   $precision:     how many pixels each media query should cover
//   $ease:          easing function to use when calculating value
//                   helpful for fine-tuning some widths in the mid-range
=spread($property, $property-min, $property-max, $dimension: min-width, $dimension-min: 400px, $dimension-max: 1400px, $default-value: true, $precision: 50px, $ease: linear)
  $total-iterations: abs(strip-units(ceil(($dimension-max - $dimension-min) / $precision))) - 1
  $max-dimension:    $dimension == max-width or $dimension == max-height

  @if $default-value
    #{$property}: if($max-dimension, $property-max, $property-min)

  @for $iteration from 0 through $total-iterations
    $iteration: if($max-dimension, $total-iterations - $iteration, $iteration)
    @media (#{$dimension}: $dimension-min + ($iteration * $precision))
      #{$property}: ease($iteration, $property-min, $property-max - $property-min, $total-iterations, $ease)

// demo styles
  font-family: sans-serif
  margin: 25px

  +spread(font-size, 20px, 35px)
  font-weight: bold

  background: #eee
  border: #ccc 1px solid
  font-size: 12px
  padding: 5px

  white-space: nowrap

  background: #fff
  border: #ccc 1px solid
  border-radius: 2px
  padding: 0 5px

  padding: 5px
  margin: -10px 0 40px

  margin: 0
  padding: 0

  font-size: 14px
  list-style-type: none
  margin: 0 0 10px
  padding: 5px
  white-space: nowrap

// demo classes
  +spread(font-size, 16px, 25px)

  +spread(font-size, 16px, 25px, $ease: out-quint)

  +spread(font-size, 16px, 25px, $dimension-max: 799px, $ease: out-quint)
  +spread(font-size, 40px, 25px, $dimension-min: 800px, $ease: out-quint, $default-value: false)

  +spread(font-size, 16px, 25px, $default-value: false)

  +spread(font-size, 16px, 25px, $precision: 5)

  +spread(width, 90%, 30%)

  +spread(margin-left, 0, -50px)

  +spread(height, 30px, 100px, min-height)

  +spread(padding-bottom, 5px, 50px, min-height)
  +spread(padding-left, 5px, 50px)
  +spread(padding-right, 5px, 50px)
  +spread(padding-top, 5px, 50px, min-height)

  +spread(font-size, 16px, 25px, max-width)