미디어
그림
가장자리를 다듬은 이미지나 동영상을 캡션과 함께 표시합니다.
이 페이지의 내용
그림 컴포넌트는 이미지, 동영상, 삽화에 캡션을 붙여 표시합니다. 미디어에는 표면과 같은 모서리 형태를 적용하고 가장자리 바로 안쪽에 아주 얇은 테두리를 둘러, 밝은 이미지가 페이지 배경에 묻히거나 어두운 이미지의 경계가 지나치게 도드라지는 것을 막습니다. 캡션은 미디어 바로 아래에 눈에 띄지 않게 배치합니다. 독자가 확대해서 볼 만한 이미지는 라이트박스에서 열 수 있습니다.
그림
<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에 설정합니다 |