【CSSリファレンス】caption-side
こんにちは(・∀・)
CSSプロパティのご紹介です。今回ご紹介するCSSプロパティはcaption-sideです。
概要
caption-sideプロパティを使用してテーブルのキャプションの位置を指定します。
.sample {
caption-side: top;
}
適用要素
caption要素
leftとrightの指定はブラウザによっては機能しない場合があります。leftまたはrightを指定する場合caption要素のwidthを指定しないとうまく機能しません。
指定できる値
- top
- テーブルの上に表示
- bottom
- テーブルの下に表示
- left
- テーブルの左に表示
- rigth
- テーブルの右に表示
初期値
top
サンプル
HTML
<table>
<caption>キャプションの位置をCSSで指定できます。</caption>
<tr>
<td>サンプルデモ</td>
<td>サンプルデモ</td>
</tr>
<tr>
<td>サンプルデモ</td>
<td>サンプルデモ</td>
</tr>
</table>
CSS
table {
border: 2px solid #9fb7d4;
border-collapse: separate;
}
table td {
border: 2px solid #d49fc2;
}
table caption {
caption-side: bottom;
}
Result
サンプルデモ | サンプルデモ |
サンプルデモ | サンプルデモ |