メディア
図版
縁を整えた、キャプション付きの画像や動画。
このページの内容
画像、動画、イラストにキャプションを添えます。メディアの角にはサーフェスと同じ丸みを付け、縁のすぐ内側を極細の線で囲みます。淡い画像の境界がページに溶け込まず、暗い画像の縁も唐突に途切れて見えません。キャプションはメディアのすぐ下に控えめに表示します。読者が拡大して見たいと思うような画像はライトボックスで開けます。
図版
<figure class="figure max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 3 / 2"> <figcaption class="figure-caption"> Moonstone under a north light, the stone the light theme is named for. </figcaption></figure><figure className="figure max-w(360) mx-auto"> <img className="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style={{ '--figure-ratio': '3 / 2' } as React.CSSProperties} /> <figcaption className="figure-caption"> Moonstone under a north light, the stone the light theme is named for. </figcaption></figure><figure class="figure max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 3 / 2"> <figcaption class="figure-caption"> Moonstone under a north light, the stone the light theme is named for. </figcaption></figure><template> <figure class="figure max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 3 / 2"> <figcaption class="figure-caption"> Moonstone under a north light, the stone the light theme is named for. </figcaption> </figure></template>メディアに--figure-ratioを指定すると、読み込み前からその縦横比で領域を確保し、読み込み後はメディアが領域全体を覆います。指定を省くと、メディア本来の縦横比を保ちます。どちらの場合も、ブラウザーが領域を確保できるよう、<img>にはwidthとheightを記述します。
#フレーム付き
figure-framedは、台紙に写真を収めるように、メディアをフレームの縁から4px内側に配置します。キャプションもフレーム内に移ります。フレームの角丸の半径はメディアの角丸の半径にその余白を足した値なので、角でも間隔が一定です。
フレーム付き
<figure class="figure figure-framed max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 16 / 9"> <figcaption class="figure-caption">Figure 2. The same stone, framed.</figcaption></figure><figure className="figure figure-framed max-w(360) mx-auto"> <img className="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style={{ '--figure-ratio': '16 / 9' } as React.CSSProperties} /> <figcaption className="figure-caption">Figure 2. The same stone, framed.</figcaption></figure><figure class="figure figure-framed max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 16 / 9"> <figcaption class="figure-caption">Figure 2. The same stone, framed.</figcaption></figure><template> <figure class="figure figure-framed max-w(360) mx-auto"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone with a band of light across it" style="--figure-ratio: 16 / 9"> <figcaption class="figure-caption">Figure 2. The same stone, framed.</figcaption> </figure></template>#中央揃え
figure-centerは、本文の段に単独で置く図版向けに、キャプションを中央揃えにして各行の長さが均等になるよう折り返します。
中央揃え
<figure class="figure figure-center max-w(240) mx-auto"> <img class="figure-media" src="/demo/portrait-2.svg" alt="Alan Turing" style="--figure-ratio: 1"> <figcaption class="figure-caption">Alan Turing, drawn for the avatar examples.</figcaption></figure><figure className="figure figure-center max-w(240) mx-auto"> <img className="figure-media" src="/demo/portrait-2.svg" alt="Alan Turing" style={{ '--figure-ratio': '1' } as React.CSSProperties} /> <figcaption className="figure-caption">Alan Turing, drawn for the avatar examples.</figcaption></figure><figure class="figure figure-center max-w(240) mx-auto"> <img class="figure-media" src="/demo/portrait-2.svg" alt="Alan Turing" style="--figure-ratio: 1"> <figcaption class="figure-caption">Alan Turing, drawn for the avatar examples.</figcaption></figure><template> <figure class="figure figure-center max-w(240) mx-auto"> <img class="figure-media" src="/demo/portrait-2.svg" alt="Alan Turing" style="--figure-ratio: 1"> <figcaption class="figure-caption">Alan Turing, drawn for the avatar examples.</figcaption> </figure></template>#アクセシビリティ
<figure>には<figcaption>を組み合わせます。キャプションが図版のアクセシブルな名前になります。- キャプションがあっても
altは必要です。代替テキストは画像に何が写っているかを伝え、キャプションはその画像を掲載する理由を伝えます。キャプションで必要な情報をすべて伝えている場合は、alt=""と指定して、同じ内容が二重に読み上げられるのを防ぎます。 - メディアの縁の内側にある線は装飾で、配色設定に従います。強制カラーモードでは、フレーム付きの図版にシステムのアウトラインが適用されます。
#クラス
| クラス | 説明 |
|---|---|
figure | メディアの下にキャプションを置く図版。 |
figure-framed | メディアはトレイの端から 4px 内側に収まり、キャプションは枠内に配置されます。figure と併用します |
figure-center | 本文のカラムに単独で置く図版向けのキャプション。中央揃えにし、各行の長さのバランスを整えます。figure と併用します |
figure-media | img、video、svg、または任意のブロックに、サーフェスの角丸と、縁の内側に沿った細い輪郭線を適用。 |
figure-caption | メディアの下に置く、小さく控えめなキャプション |
#カスタムプロパティ
| プロパティ | 既定値 | 説明 |
|---|---|---|
--figure-radius | var(--radius-surface) | メディアの角丸 |
--figure-ratio | メディアのアスペクト比。読み込み前からその比率の領域を確保し、読み込み後はメディアが領域全体を覆います。未指定の場合はメディア本来の比率を保ちます。指定先:figure-media |