Skip to main content Skip to docs navigation

タイポグラフィ Typography

グローバル設定、見出し、本文テキスト、リストなど、Bootstrapのタイポグラフィに関するドキュメントと例です。

グローバル設定

Bootstrapは、基本的なグローバルな表示、タイポグラフィ、リンクスタイルを設定します。より細かい制御が必要な場合は、テキストユーティリティクラスを確認してください。

  • 各OSとデバイスに最適なfont-familyを選択するネイティブフォントスタックを使用します。
  • より包括的でアクセシブルなタイプスケールのために、ブラウザのデフォルトルートfont-size(通常16px)を使用し、訪問者が必要に応じてブラウザのデフォルトをカスタマイズできるようにします。
  • <body>に適用されるタイポグラフィベースとして、$font-family-base$font-size-base$line-height-base属性を使用します。
  • $link-colorを介してグローバルリンクカラーを設定します。
  • $body-bgを使用して<body>background-colorを設定します(デフォルトは#fff)。

これらのスタイルは_reboot.scss内にあり、グローバル変数は_variables.scssで定義されています。必ず$font-size-baseremで設定してください。

見出し

すべてのHTML見出し、<h1>から<h6>まで利用可能です。

HeadingExample
<h1></h1>h1. Bootstrap heading
<h2></h2>h2. Bootstrap heading
<h3></h3>h3. Bootstrap heading
<h4></h4>h4. Bootstrap heading
<h5></h5>h5. Bootstrap heading
<h6></h6>h6. Bootstrap heading
<h1>h1. Bootstrap heading</h1>
<h2>h2. Bootstrap heading</h2>
<h3>h3. Bootstrap heading</h3>
<h4>h4. Bootstrap heading</h4>
<h5>h5. Bootstrap heading</h5>
<h6>h6. Bootstrap heading</h6>

.h1から.h6クラスも利用可能で、見出しのフォントスタイルに合わせたいが、関連するHTML要素を使用できない場合に使用します。

h1. Bootstrap heading

h2. Bootstrap heading

h3. Bootstrap heading

h4. Bootstrap heading

h5. Bootstrap heading

h6. Bootstrap heading

html
<p class="h1">h1. Bootstrap heading</p>
<p class="h2">h2. Bootstrap heading</p>
<p class="h3">h3. Bootstrap heading</p>
<p class="h4">h4. Bootstrap heading</p>
<p class="h5">h5. Bootstrap heading</p>
<p class="h6">h6. Bootstrap heading</p>

見出しのカスタマイズ

Bootstrap 3の小さなセカンダリ見出しテキストを再現するために、含まれているユーティリティクラスを使用します。

Fancy display heading With faded secondary text

html
<h3>
  Fancy display heading
  <small class="text-body-secondary">With faded secondary text</small>
</h3>

ディスプレイ見出し

従来の見出し要素は、ページコンテンツの本文で最適に機能するように設計されています。見出しを目立たせる必要がある場合は、ディスプレイ見出しの使用を検討してください。これは、より大きく、やや独自性のある見出しスタイルです。

Display 1
Display 2
Display 3
Display 4
Display 5
Display 6
<h1 class="display-1">Display 1</h1>
<h1 class="display-2">Display 2</h1>
<h1 class="display-3">Display 3</h1>
<h1 class="display-4">Display 4</h1>
<h1 class="display-5">Display 5</h1>
<h1 class="display-6">Display 6</h1>

ディスプレイ見出しは、$display-font-sizes Sassマップと2つの変数、$display-font-weight$display-line-heightを介して設定されます。

ディスプレイ見出しは、2つの変数、$display-font-family$display-font-styleを介してカスタマイズ可能です。

$display-font-sizes: (
  1: 5rem,
  2: 4.5rem,
  3: 4rem,
  4: 3.5rem,
  5: 3rem,
  6: 2.5rem
);

$display-font-family: null;
$display-font-style:  null;
$display-font-weight: 300;
$display-line-height: $headings-line-height;

リード

.leadを追加して段落を目立たせます。

This is a lead paragraph. It stands out from regular paragraphs.

html
<p class="lead">
  This is a lead paragraph. It stands out from regular paragraphs.
</p>

インラインテキスト要素

一般的なインラインHTML5要素のスタイリングです。

You can use the mark tag to highlight text.

This line of text is meant to be treated as deleted text.

This line of text is meant to be treated as no longer accurate.

This line of text is meant to be treated as an addition to the document.

This line of text will render as underlined.

This line of text is meant to be treated as fine print.

This line rendered as bold text.

This line rendered as italicized text.

html
<p>You can use the mark tag to <mark>highlight</mark> text.</p>
<p><del>This line of text is meant to be treated as deleted text.</del></p>
<p><s>This line of text is meant to be treated as no longer accurate.</s></p>
<p><ins>This line of text is meant to be treated as an addition to the document.</ins></p>
<p><u>This line of text will render as underlined.</u></p>
<p><small>This line of text is meant to be treated as fine print.</small></p>
<p><strong>This line rendered as bold text.</strong></p>
<p><em>This line rendered as italicized text.</em></p>

これらのタグは、意味的な目的で使用する必要があることに注意してください:

  • <mark>は、参照または注釈目的でマークまたは強調表示されたテキストを表します。
  • <small>は、著作権や法的テキストのような、サイドコメントや小さな印刷物を表します。
  • <s>は、もはや関連性がないか、もはや正確ではない要素を表します。
  • <u>は、テキスト以外の注釈があることを示す方法でレンダリングされるべきインラインテキストのスパンを表します。

テキストをスタイリングしたい場合は、代わりに以下のクラスを使用してください:

  • .mark<mark>と同じスタイルを適用します。
  • .small<small>と同じスタイルを適用します。
  • .text-decoration-underline<u>と同じスタイルを適用します。
  • .text-decoration-line-through<s>と同じスタイルを適用します。

上記には示されていませんが、HTML5で<b><i>を自由に使用してください。<b>は、追加の重要性を伝えることなく単語やフレーズを強調することを意図しており、<i>は主に音声、技術用語などに使用されます。

テキストユーティリティ

テキストユーティリティおよびカラーユーティリティを使用して、テキストの配置、変換、スタイル、太さ、行の高さ、装飾、色を変更します。

略語

略語と頭字語のためのHTMLの<abbr>要素のスタイル化された実装で、ホバー時に展開されたバージョンを表示します。略語にはデフォルトの下線があり、ヘルプカーソスが表示され、ホバー時および支援技術のユーザーに追加のコンテキストを提供します。

やや小さなフォントサイズのために、略語に.initialismを追加します。

attr

HTML

html
<p><abbr title="attribute">attr</abbr></p>
<p><abbr title="HyperText Markup Language" class="initialism">HTML</abbr></p>

ブロッククォート

ドキュメント内の別のソースからのコンテンツブロックを引用するために使用します。引用として任意のHTMLの周りに<blockquote class="blockquote">をラップします。

A well-known quote, contained in a blockquote element.

html
<blockquote class="blockquote">
  <p>A well-known quote, contained in a blockquote element.</p>
</blockquote>

ソースの命名

HTML仕様では、ブロッククォートの帰属は<blockquote>の外側に配置する必要があります。帰属を提供する場合は、<blockquote><figure>でラップし、.blockquote-footerクラスを持つ<figcaption>またはブロックレベル要素(例:<p>)を使用します。ソース作品の名前は必ず<cite>でラップしてください。

A well-known quote, contained in a blockquote element.

html
<figure>
  <blockquote class="blockquote">
    <p>A well-known quote, contained in a blockquote element.</p>
  </blockquote>
  <figcaption class="blockquote-footer">
    Someone famous in <cite title="Source Title">Source Title</cite>
  </figcaption>
</figure>

配置

必要に応じてテキストユーティリティを使用して、ブロッククォートの配置を変更します。

A well-known quote, contained in a blockquote element.

html
<figure class="text-center">
  <blockquote class="blockquote">
    <p>A well-known quote, contained in a blockquote element.</p>
  </blockquote>
  <figcaption class="blockquote-footer">
    Someone famous in <cite title="Source Title">Source Title</cite>
  </figcaption>
</figure>

A well-known quote, contained in a blockquote element.

html
<figure class="text-end">
  <blockquote class="blockquote">
    <p>A well-known quote, contained in a blockquote element.</p>
  </blockquote>
  <figcaption class="blockquote-footer">
    Someone famous in <cite title="Source Title">Source Title</cite>
  </figcaption>
</figure>

リスト

スタイルなし

リストアイテム(直接の子のみ)のデフォルトのlist-styleと左マージンを削除します。これは直接の子リストアイテムにのみ適用されます。つまり、ネストされたリストにもクラスを追加する必要があります。

  • This is a list.
  • It appears completely unstyled.
  • Structurally, it's still a list.
  • However, this style only applies to immediate child elements.
  • Nested lists:
    • are unaffected by this style
    • will still show a bullet
    • and have appropriate left margin
  • This may still come in handy in some situations.
html
<ul class="list-unstyled">
  <li>This is a list.</li>
  <li>It appears completely unstyled.</li>
  <li>Structurally, it's still a list.</li>
  <li>However, this style only applies to immediate child elements.</li>
  <li>Nested lists:
    <ul>
      <li>are unaffected by this style</li>
      <li>will still show a bullet</li>
      <li>and have appropriate left margin</li>
    </ul>
  </li>
  <li>This may still come in handy in some situations.</li>
</ul>

インライン

リストの箇条書きを削除し、2つのクラス、.list-inline.list-inline-itemの組み合わせで軽いmarginを適用します。

  • This is a list item.
  • And another one.
  • But they're displayed inline.
html
<ul class="list-inline">
  <li class="list-inline-item">This is a list item.</li>
  <li class="list-inline-item">And another one.</li>
  <li class="list-inline-item">But they're displayed inline.</li>
</ul>

説明リストの配置

グリッドシステムの定義済みクラス(またはセマンティックミックスイン)を使用して、用語と説明を水平に配置します。長い用語の場合、オプションで.text-truncateクラスを追加して、省略記号でテキストを切り詰めることができます。

Description lists
A description list is perfect for defining terms.
Term

Definition for the term.

And some more placeholder definition text.

Another term
This definition is short, so no extra paragraphs or anything.
Truncated term is truncated
This can be useful when space is tight. Adds an ellipsis at the end.
Nesting
Nested definition list
I heard you like definition lists. Let me put a definition list inside your definition list.
html
<dl class="row">
  <dt class="col-sm-3">Description lists</dt>
  <dd class="col-sm-9">A description list is perfect for defining terms.</dd>

  <dt class="col-sm-3">Term</dt>
  <dd class="col-sm-9">
    <p>Definition for the term.</p>
    <p>And some more placeholder definition text.</p>
  </dd>

  <dt class="col-sm-3">Another term</dt>
  <dd class="col-sm-9">This definition is short, so no extra paragraphs or anything.</dd>

  <dt class="col-sm-3 text-truncate">Truncated term is truncated</dt>
  <dd class="col-sm-9">This can be useful when space is tight. Adds an ellipsis at the end.</dd>

  <dt class="col-sm-3">Nesting</dt>
  <dd class="col-sm-9">
    <dl class="row">
      <dt class="col-sm-4">Nested definition list</dt>
      <dd class="col-sm-8">I heard you like definition lists. Let me put a definition list inside your definition list.</dd>
    </dl>
  </dd>
</dl>

レスポンシブフォントサイズ

Bootstrap 5では、レスポンシブフォントサイズをデフォルトで有効にしており、デバイスとビューポートサイズ全体でテキストがより自然にスケールできるようにしています。これがどのように機能するかを確認するには、RFSページをご覧ください。

CSS

Sass変数

見出しには、サイズと間隔のための専用変数があります。

$headings-margin-bottom:      $spacer * .5;
$headings-font-family:        null;
$headings-font-style:         null;
$headings-font-weight:        500;
$headings-line-height:        1.2;
$headings-color:              inherit;

ここおよびRebootでカバーされているその他のタイポグラフィ要素にも専用変数があります。

$lead-font-size:              $font-size-base * 1.25;
$lead-font-weight:            300;

$small-font-size:             .875em;

$sub-sup-font-size:           .75em;

// fusv-disable
$text-muted:                  var(--#{$prefix}secondary-color); // Deprecated in 5.3.0
// fusv-enable

$initialism-font-size:        $small-font-size;

$blockquote-margin-y:         $spacer;
$blockquote-font-size:        $font-size-base * 1.25;
$blockquote-footer-color:     $gray-600;
$blockquote-footer-font-size: $small-font-size;

$hr-margin-y:                 $spacer;
$hr-color:                    inherit;

// fusv-disable
$hr-bg-color:                 null; // Deprecated in v5.2.0
$hr-height:                   null; // Deprecated in v5.2.0
// fusv-enable

$hr-border-color:             null; // Allows for inherited colors
$hr-border-width:             var(--#{$prefix}border-width);
$hr-opacity:                  .25;

// scss-docs-start vr-variables
$vr-border-width:             var(--#{$prefix}border-width);
// scss-docs-end vr-variables

$legend-margin-bottom:        .5rem;
$legend-font-size:            1.5rem;
$legend-font-weight:          null;

$dt-font-weight:              $font-weight-bold;

$list-inline-padding:         .5rem;

$mark-padding:                .1875em;
$mark-bg:                     $yellow-100;

Sassミックスイン

タイポグラフィ専用のミックスインはありませんが、Bootstrapはレスポンシブフォントサイジング(RFS)を使用します。