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


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.


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.


                <div style="font-size: 16px">Test 16px (Min)</div>
<div id="test">Test <span id="size"></span></div>
<div style="font-size: 24px">Test 24px (Max)</div>

<div id="vw" style="position: absolute; top: 0; right: 0;"></div>

<p>Author : <a href="">Neo</a></p>


                /// 引数に単位が付いている場合は単位を除去して数値のみ返却する
/// @param $num {number} 数値のみ返却してほしい値
/// @return {number} 引数を数値のみに変換した値
@function strip-unit($num) {
  @if type-of($num) == 'number' and not unitless($num) {
    @return $num / ($num * 0 + 1);
  @return $num;

/// 単位がない数値に px を付ける
/// @param $num {number} 単位のみの値
/// @return {number} 引数を px 単位に変換した値
@function to-px($num) {
  @return $num * 1px;

/// レスポンシブルにフォントサイズを変更する
/// @param {number} $min-font-size 最小フォントサイズ (px)
/// @param {number} $max-font-size 最大フォントサイズ (px)
/// @param {number} $min-breakpoint 最小ビューポート幅 (px)
/// @param {number} $max-breakpoint 最大ビューポート幅 (px)
/// @param {number} $root-font-size ルートのフォントサイズ・未指定時は 16 (px)
@mixin responsive-font-size($min-font-size, $max-font-size, $min-breakpoint, $max-breakpoint, $root-font-size: 16px) {
  $min-font-size-num : strip-unit($min-font-size);
  $max-font-size-num : strip-unit($max-font-size);
  $min-breakpoint-num: strip-unit($min-breakpoint);
  $max-breakpoint-num: strip-unit($max-breakpoint);
  $root-font-size-num: strip-unit($root-font-size);
  // Min Font Size
  font-size: to-px($min-font-size-num);
  // Responsive Font Size
  @media (min-width: to-px($min-breakpoint-num)) {
    $min-font-size-rem        : ($min-font-size-num / $root-font-size-num * 1rem);
    $min-breakpoint-percent-px: ($min-breakpoint-num / 100 * 1px);
    $font-size-difference     : ($max-font-size-num - $min-font-size-num);
    $breakpoint-difference    : ($max-breakpoint-num - $min-breakpoint-num);
    $differences              : (100 * $font-size-difference / $breakpoint-difference);
    font-size: calc( #{$min-font-size-rem} + ( 1vw - #{$min-breakpoint-percent-px} ) * #{$differences} );
  // Max Font Size
  @media (min-width: to-px($max-breakpoint-num)) {
    font-size: to-px($max-font-size-num);

// 16px @ 768px から 24px @ 1024px に変更する (ルートのフォントサイズは未指定で 16px として扱わせる)
html {
  @include responsive-font-size(16px, 24px, 768px, 1024px);


                /** フォントサイズとビューポート幅を出力する */
function detectSizes() {
  const test = document.getElementById('test');
  const size = document.getElementById('size');
  const vw   = document.getElementById('vw');
  size.innerHTML = window.getComputedStyle(test).fontSize;
  vw.innerHTML   = window.innerWidth + 'px';

document.addEventListener('DOMContentLoaded', detectSizes);
document.addEventListener('resize', detectSizes);