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

              
                <!-- デモ用フォントの読み込み -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap" rel="stylesheet">

<!-- ドロップダウンでフォントを選ぶ場合、スタイル切り替えの際にフォールバックフォントが一瞬表示されることがあるためプリロードしておく -->
<link rel="preload" href="path" as="font" type="font/woff2" crossorigin />

<!-- font-weight, font-style / ドロップダウンでスタイルを選択する場合 -->
<div class="typeface" id='dmsans'>
  <select name="weight" class="typeface__select">
    <!--   weight-styleをvalueに記述する -->
    <option value="400-normal" selected>Regular</option>
    <option value="400-italic">Regular Italic</option>
    <option value="500-normal">Medium</option>
    <option value="500-italic">Medium Italic</option>
    <option value="700-normal">Bold</option>
    <option value="700-italic">Bold Italic</option>
  </select>
  <div class="typeface__features">
    <!--   適用できるOpenType機能をvalueに入れたチェックボックスを作る -->
    <label><input value='kern' class="typeface__check" type="checkbox" checked>kern</label>
    <label><input value='liga' class="typeface__check" type="checkbox" checked>liga</label>
    <label><input value='ss01' class="typeface__check" type="checkbox">ss01</label>
    <label><input value='ss02' class="typeface__check" type="checkbox">ss02</label>
    <label><input value='ss03' class="typeface__check" type="checkbox">ss03</label>
    <label><input value='ss04' class="typeface__check" type="checkbox">ss04</label>
  </div>
  <!--     フォントサイズの調整スライダー -->
  <input class="typeface__fontsize" type="range" name="size" min="4" max="200" value="36">
  <textarea class="typeface__area">Test Typeface with font-weight and font-style</textarea>
</div>
<!-- font-familyをドロップダウンで選択する場合 -->
<div class="typeface" id='koga'>
  <select name="weight" class="typeface__select">
    <!-- font-familyをvalueに記述する -->
    <option value="koga-sans-book" selected>Book</option>
    <option value="koga-sans-medium">Medium</option>
    <option value="koga-sans-semibold">Semi Bold</option>
    <option value="koga-sans-bold">Bold</option>
  </select>
  <div class="typeface__features">
    <!--   適用できるOpenType機能をvalueに入れたチェックボックスを作る -->
    <label><input value='kern' class="typeface__check" type="checkbox" checked>kern</label>
    <label><input value='onum' class="typeface__check" type="checkbox">onum</label>
    <label><input value='smcp' class="typeface__check" type="checkbox">smcp</label>
    <label><input value='ss01' class="typeface__check" type="checkbox">ss01</label>
    <label><input value='ss02' class="typeface__check" type="checkbox">ss02</label>
    <label><input value='ss03' class="typeface__check" type="checkbox">ss03</label>
    <label><input value='ss04' class="typeface__check" type="checkbox">ss04</label>
  </div>
  <!--     フォントサイズの調整スライダー -->
  <input class="typeface__fontsize" type="range" name="size" min="4" max="200" value="36">
  <textarea class="typeface__area">Test Typeface with font-family</textarea>
</div>

<!-- バリアブルフォントをスライダーで調整する場合 -->
<div class="typeface" id='modern'>
  <input class="typeface__slider" type="range" name="weight" min="100" max="900" value="400">
  <div class="typeface__features">
    <!--   適用できるOpenType機能をvalueに入れたチェックボックスを作る -->
    <label><input value='kern' class="typeface__check" type="checkbox" checked>kern</label>
    <label><input value='onum' class="typeface__check" type="checkbox">onum</label>
    <label><input value='dlig' class="typeface__check" type="checkbox">dlig</label>
    <label><input value='ss01' class="typeface__check" type="checkbox">ss01</label>
    <label><input value='ss02' class="typeface__check" type="checkbox">ss02</label>
    <label><input value='ss03' class="typeface__check" type="checkbox">ss03</label>
    <label><input value='ss04' class="typeface__check" type="checkbox">ss04</label>
  </div>
  <!--     フォントサイズの調整スライダー -->
  <input class="typeface__fontsize" type="range" name="size" min="4" max="200" value="36">
  <textarea class="typeface__area">Test Typeface with font-variation-settings</textarea>
</div>
              
            
!

CSS

              
                // デモ用書体の読み込み
@font-face {
  font-family: "koga-sans-book";
  src: url("https://wolphtype.com/font/KogaSansText-Book.woff2") format("woff2");
}
@font-face {
  font-family: "koga-sans-medium";
  src: url("https://wolphtype.com/font/KogaSansText-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "koga-sans-semiBold";
  src: url("https://wolphtype.com/font/KogaSansText-SemiBold.woff2") format("woff2");
}
@font-face {
  font-family: "koga-sans-bold";
  src: url("https://wolphtype.com/font/KogaSansText-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Koga Sans Modern";
  src: url("https://wolphtype.com/font/KogaSansModernVF.woff2") format("woff2");
}

// スタイリング
.typeface {
  margin-top: 30px;
  margin-left: 30px;
  &__features{
    margin-top: 20px;
  }
  &__fontsize{
    display: block;
    margin-top: 20px;
  }
  &__area{
    appearance: none;
    border: none;
    background-color: #eee;
    margin-top: 20px;
    padding: 10px;
    width: 80%;
    height: 300px;
    font-size: 36px;
    &:focus {
      outline: none;
    }
  }
}
#dmsans{
  font-family: "DM Sans", sans-serif;
  textarea{
    font-family: "DM Sans", sans-serif;
  }
}
#koga{
  font-family: "koga-sans-book", sans-serif;
  textarea{
    font-family: 'koga-sans-book', sans-serif;
  }
}
#modern{
  font-family: "Koga Sans Modern", sans-serif;
  textarea{
    font-family: 'Koga Sans Modern', sans-serif;
  }
}

              
            
!

JS

              
                // フォントサイズ変更
$('.typeface__fontsize').on('input', function() {
  const fontSize = $(this).val();
  console.log(fontSize);
  $(this).nextAll('textarea').css('font-size', fontSize + 'px') 
// ↑場所によってtextareaに当たるように変更する
});
// font-weightとfont-styleでスタイルを変更
$('#dmsans .typeface__select').change(function() {
  var property = $(this).find('option:selected').val();
  var weightStyle = property.split('-');
  $('#dmsans textarea').css({'font-weight':weightStyle[0], 'font-style':weightStyle[1]})
});
// --dmsansのOpenType機能を変更
$('#dmsans .typeface__check').click(function() {
  var checked = $('#dmsans .typeface__check:checked').map(function() {
    return $(this).val();
  }).get();
  features = checked.join('\', \'');
  features = '\'' + features + '\'';
  $('#dmsans textarea').css('font-feature-settings', features)
});

// font-familyでスタイルを変更
$('#koga .typeface__select').change(function() {
  var style = $(this).find('option:selected').val();
  $('#koga textarea').css('font-family', style)
});
// #kogaのOpenType機能を変更
$('#koga .typeface__check').click(function() {
  var checked = $('#koga .typeface__check:checked').map(function() {
    return $(this).val();
  }).get();
  features = checked.join('\', \'');
  features = '\'' + features + '\'';
  $('#koga textarea').css('font-feature-settings', features)
});

// スライダーでバリアブルフォントを調整
$('#modern .typeface__slider').on('input', function() {
  const weight = $(this).val();
// 複数軸の場合, const italic = $(#italic).val();のようにそれぞれ定義する
  $('#modern textarea').css('font-variation-settings', `'wght' ${weight}`)
// 複数軸の場合、$('#modern textarea').css('font-variation-settings', `'wght' ${weight}, 'ital' ${italic}`) のように書く
});
              
            
!
999px

Console