css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

              <h1>英語 + 和英混在 Sans-Serif フォントのテスト</h1>
<div id="wrapper"></div>
              *, ::before, ::after { box-sizing: border-box; }
html { overflow-y: scroll; -webkit-text-size-adjust: 100%; }
body { margin: 1rem; line-height: 1.7; }
html, body { font-size: 14px; font-family: "游明朝体", YuMincho, "游明朝", "Yu Mincho", serif; }
h1, h2, h3, h4, h5, h6, p, hr, dl, dt, dd, ol, l, pre, table { margin-top: 0; margin-bottom: 1rem; }
@font-face { font-family: "Yu Gothic M"; src: local("Yu Gothic Medium"); }
@font-face { font-family: "Yu Gothic M"; src: local("Yu Gothic Bold"); font-weight: bold; }

.example { position: relative; margin-left: 120px; padding-left: 1rem; width: calc(50% - 120px); }
.example .checkbox { position: absolute; }
.example .title { font-size: 1.05rem; font-weight: bold; }
.overlay { position: fixed; top: 1rem; left: 50%; }
              function createCss(id, css) {
  return `#${id} { font-family: ${css}, "游明朝体", YuMincho, "游明朝", "Yu Mincho", serif; }`;
function createHtml(id, title, checkboxOffsetX, checkboxOffsetY) {
  return `
    <div class="example" id="${id}">
      <input type="checkbox" class="checkbox" style="top: ${checkboxOffsetY}px; left: ${checkboxOffsetX}px;">
      <div class="title">${title}</div>
      <div class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit,<br>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br>lorem ipsum (ロレム・イプサム、略してリプサム lipsum ともいう) とは、<br>出版、Web デザイン、Graphic デザインなどの諸分野において使用されているテキスト。<br>書籍やウェブページや広告などのデザインのプロトタイプを制作したり顧客に<br>プレゼンテーションしたりする際に、視覚的なデザインを調整したりわかりやすく見せる。</div>
function toggle(id) {

const enFonts = [
  { title: '-apple-system' , name: 'a', css: '-apple-system, BlinkMacSystemFont' },
  { title: 'Helvetica Neue', name: 'n', css: '"Helvetica Neue", HelveticaNeue'   },
  { title: 'Helvetica'     , name: 'h', css: 'Helvetica'                         },
  { title: 'Arial'         , name: 'r', css: 'Arial'                             },
  { title: 'Segoe UI'      , name: 's', css: '"Segoe UI"'                        }
const jaFonts = [
  { title: 'YuGothic'   , name: 'y', css: '"游ゴシック体", YuGothic, "Yu Gothic M", "游ゴシック Medium", "Yu Gothic Medium"' },
  { title: 'Hiragino'   , name: 'h', css: '"ヒラギノ角ゴ ProN W3", "Hiragino Kaku Gothic ProN W3", HiraKakuProN-W3, "ヒラギノ角ゴ ProN", "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ Pro", "Hiragino Kaku Gothic Pro"' },
  { title: 'Meiryo'     , name: 'm', css: '"メイリオ", Meiryo' },
  { title: 'Osaka'      , name: 'o', css: 'Osaka' },
  { title: 'MS P Gothic', name: 'p', css: '"MS Pゴシック", "MS PGothic"' }

document.addEventListener('DOMContentLoaded', () => {
  const wrapper = document.getElementById('wrapper');
  let style = '<style>';
  const checkboxSize = 20;
  const negativeOffset = enFonts.length * -checkboxSize;
  jaFonts.forEach((jaFont, indexY) => {
    const offsetY = indexY * checkboxSize;
    // 和英混在フォントのみ出力
    const jaOnlyId = `f${jaFont.name}`;
    style += createCss(jaOnlyId, jaFont.css);
    const jaOnlyOffsetX = negativeOffset - checkboxSize;
    const jaOnlyHtml = createHtml(jaOnlyId, jaFont.title, jaOnlyOffsetX, offsetY);
    wrapper.insertAdjacentHTML('beforeend', jaOnlyHtml);
    document.querySelector(`#${jaOnlyId} input`).addEventListener('click', () => { toggle(jaOnlyId); });
    // 英字フォントを手前に配置したバリエーション
    enFonts.forEach((enFont, indexX) => {
      const id = `f${enFont.name}${jaFont.name}`;
      style += createCss(id, `${enFont.css}, ${jaFont.css}`);
      const offsetX = negativeOffset + indexX * checkboxSize;
      const html = createHtml(id, `${enFont.title} + ${jaFont.title}`, offsetX, offsetY);
      wrapper.insertAdjacentHTML('beforeend', html);
      document.querySelector(`#${id} input`).addEventListener('click', () => { toggle(id); });
  style += '</style>';
  wrapper.insertAdjacentHTML('beforebegin', style);
🕑 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.
Loading ..................