ホットスポット
画像上の位置にピンを置き、そこに何があるかを伝えます。製品の各部や図面上の場所などに。
このページの内容
ホットスポットは画像上にピンを置き、製品の各部、図面上の位置、スクリーンショットで注目してほしい箇所などを示します。ホットスポットは画像を囲む枠で、各ピンはパーセント指定で配置するボタンです。ピンは通常のボタンと同様に動作するため、スクリプトなしでポップオーバーを開けます。
ホットスポット
<figure class="figure hotspot w-full max-w(480)"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone hanging over two ranges of grey hills" style="--figure-ratio: 16 / 9"> <button class="hotspot-pin" type="button" style="--x: 72%; --y: 32%" popovertarget="spot-stone" aria-label="The stone"> 1 </button> <div class="popover" id="spot-stone" popover> <p class="m(0) fg-text-strong font-medium">The stone</p> <p class="m(0) fg-text-muted"> Moonstone, lit from above and slightly left, as every surface in the theme is. </p> </div> <button class="hotspot-pin" type="button" style="--x: 30%; --y: 62%" popovertarget="spot-hills" aria-label="The far hills"> 2 </button> <div class="popover" id="spot-hills" popover> <p class="m(0) fg-text-strong font-medium">The far hills</p> <p class="m(0) fg-text-muted">One step of the same grey lighter than the near ones.</p> </div></figure><figure className="figure hotspot w-full max-w(480)"> <img className="figure-media" src="/demo/moonstone.svg" alt="A pale stone hanging over two ranges of grey hills" style={{ '--figure-ratio': '16 / 9' } as React.CSSProperties} /> <button className="hotspot-pin" type="button" style={{ '--x': '72%', '--y': '32%' } as React.CSSProperties} popoverTarget="spot-stone" aria-label="The stone"> 1 </button> <div className="popover" id="spot-stone" popover=""> <p className="m(0) fg-text-strong font-medium">The stone</p> <p className="m(0) fg-text-muted"> Moonstone, lit from above and slightly left, as every surface in the theme is. </p> </div> <button className="hotspot-pin" type="button" style={{ '--x': '30%', '--y': '62%' } as React.CSSProperties} popoverTarget="spot-hills" aria-label="The far hills"> 2 </button> <div className="popover" id="spot-hills" popover=""> <p className="m(0) fg-text-strong font-medium">The far hills</p> <p className="m(0) fg-text-muted">One step of the same grey lighter than the near ones.</p> </div></figure><figure class="figure hotspot w-full max-w(480)"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone hanging over two ranges of grey hills" style="--figure-ratio: 16 / 9"> <button class="hotspot-pin" type="button" style="--x: 72%; --y: 32%" popovertarget="spot-stone" aria-label="The stone"> 1 </button> <div class="popover" id="spot-stone" popover> <p class="m(0) fg-text-strong font-medium">The stone</p> <p class="m(0) fg-text-muted"> Moonstone, lit from above and slightly left, as every surface in the theme is. </p> </div> <button class="hotspot-pin" type="button" style="--x: 30%; --y: 62%" popovertarget="spot-hills" aria-label="The far hills"> 2 </button> <div class="popover" id="spot-hills" popover> <p class="m(0) fg-text-strong font-medium">The far hills</p> <p class="m(0) fg-text-muted">One step of the same grey lighter than the near ones.</p> </div></figure><template> <figure class="figure hotspot w-full max-w(480)"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone hanging over two ranges of grey hills" style="--figure-ratio: 16 / 9"> <button class="hotspot-pin" type="button" style="--x: 72%; --y: 32%" popovertarget="spot-stone" aria-label="The stone"> 1 </button> <div class="popover" id="spot-stone" popover> <p class="m(0) fg-text-strong font-medium">The stone</p> <p class="m(0) fg-text-muted"> Moonstone, lit from above and slightly left, as every surface in the theme is. </p> </div> <button class="hotspot-pin" type="button" style="--x: 30%; --y: 62%" popovertarget="spot-hills" aria-label="The far hills"> 2 </button> <div class="popover" id="spot-hills" popover> <p class="m(0) fg-text-strong font-medium">The far hills</p> <p class="m(0) fg-text-muted">One step of the same grey lighter than the near ones.</p> </div> </figure></template>#ピンの配置
hotspotを指定すると、画像を囲む要素が画像と同じ幅になり、ピンの配置基準になります。各hotspot-pinのスタイルに--xと--yを設定し、画像の左上を起点に、横位置は画像の幅に対する割合、縦位置は高さに対する割合を、それぞれパーセントで指定します。ピンの中心が指定した座標に揃い、画像のサイズが変わっても同じ箇所を指します。
ピンには<button>を使い、別の場所に移動する場合はリンクを使います。popovertargetを指定するとポップオーバーが開きます。アンカー配置に対応するブラウザーではピンに隣接して、未対応の場合はビューポートの中央に表示されます。interestforを指定すると、ホバー時とフォーカス時にツールチップが表示されます。
#ピン
ピンは前景色で塗りつぶした直径24pxの円で、白い縁取りと、その外側に濃い影が付きます。画像自体はテーマに合わせて変わらないため、縁取りと影は両テーマで共通です。この組み合わせにより、明るい画像でも暗い画像でもピンを見つけやすくなります。ピンに番号を表示して本文の一覧と対応させることも、番号なしで表示することもできます。
数秒おきにピンからリングが広がり、押せることを示します。動きを抑える設定では、リングは静止します。タッチスクリーンでは見た目のサイズを保ち、タップ領域を44pxに広げます。
番号なし
<figure class="figure hotspot w-full max-w(360)"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone hanging over two ranges of grey hills" style="--figure-ratio: 16 / 9"> <button class="hotspot-pin" type="button" style="--x: 72%; --y: 32%" popovertarget="plain-stone" aria-label="The stone"></button> <div class="popover" id="plain-stone" popover>The stone the light theme is named for.</div> <button class="hotspot-pin" type="button" style="--x: 22%; --y: 78%" popovertarget="plain-hills" aria-label="The near hills"></button> <div class="popover" id="plain-hills" popover>The near hills, in the ink of the page.</div></figure><figure className="figure hotspot w-full max-w(360)"> <img className="figure-media" src="/demo/moonstone.svg" alt="A pale stone hanging over two ranges of grey hills" style={{ '--figure-ratio': '16 / 9' } as React.CSSProperties} /> <button className="hotspot-pin" type="button" style={{ '--x': '72%', '--y': '32%' } as React.CSSProperties} popoverTarget="plain-stone" aria-label="The stone"></button> <div className="popover" id="plain-stone" popover="">The stone the light theme is named for.</div> <button className="hotspot-pin" type="button" style={{ '--x': '22%', '--y': '78%' } as React.CSSProperties} popoverTarget="plain-hills" aria-label="The near hills"></button> <div className="popover" id="plain-hills" popover="">The near hills, in the ink of the page.</div></figure><figure class="figure hotspot w-full max-w(360)"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone hanging over two ranges of grey hills" style="--figure-ratio: 16 / 9"> <button class="hotspot-pin" type="button" style="--x: 72%; --y: 32%" popovertarget="plain-stone" aria-label="The stone"></button> <div class="popover" id="plain-stone" popover>The stone the light theme is named for.</div> <button class="hotspot-pin" type="button" style="--x: 22%; --y: 78%" popovertarget="plain-hills" aria-label="The near hills"></button> <div class="popover" id="plain-hills" popover>The near hills, in the ink of the page.</div></figure><template> <figure class="figure hotspot w-full max-w(360)"> <img class="figure-media" src="/demo/moonstone.svg" alt="A pale stone hanging over two ranges of grey hills" style="--figure-ratio: 16 / 9"> <button class="hotspot-pin" type="button" style="--x: 72%; --y: 32%" popovertarget="plain-stone" aria-label="The stone"></button> <div class="popover" id="plain-stone" popover>The stone the light theme is named for.</div> <button class="hotspot-pin" type="button" style="--x: 22%; --y: 78%" popovertarget="plain-hills" aria-label="The near hills"></button> <div class="popover" id="plain-hills" popover>The near hills, in the ink of the page.</div> </figure></template>#アクセシビリティ
- 各ピンには、
aria-label="The arm"のように、何を指しているかが分かるアクセシブルな名前を付けます。「ピン1」のような名前では対象が伝わりません。ピン内に番号を表示する場合も、対象を示すアクセシブルな名前を付けます。 - Tabキーでピンにフォーカスすると、マークアップに記述した順に移動します。追加した順序にかかわらず、読者が画像を見る順序で記述します。
- 画像の
altには、画像全体の説明を記述します。ピンを操作しなくても同じ情報が得られるように、画像の下に各箇所の説明を一覧にし、ピンと同じ番号を付けます。 - スマートフォンで表示される可能性のある画像では、タップ領域が重ならないように、ピン同士を44px以上離します。
#クラス
| クラス | 説明 |
|---|---|
hotspot | 画像と同じ幅のフレーム。ピンはこのフレームを基準に配置します。 |
hotspot-pin | アクセシブルな名前を持つボタンに適用するピンです。前景色で塗りつぶした直径 24px の円に白い縁が付き、中心は --x と --y で指定した位置に来ます。円の中には数字を入れられます。ときどき輪が外側に広がり、ポインターがピンに重なっている間やピンにフォーカスがある間はアニメーションが止まります。 |
#カスタムプロパティ
| プロパティ | 既定値 | 説明 |
|---|---|---|
--x | 画像の左端を起点とするピンの横位置(%)。指定先:hotspot-pin | |
--y | 画像の上端を起点とするピンの縦位置(%)。指定先:hotspot-pin |