Skip to content

Commit c93875f

Browse files
committed
doc: add <caption> tag document.
1 parent b7f4465 commit c93875f

File tree

1 file changed

+82
-2
lines changed

1 file changed

+82
-2
lines changed

docs/tags/caption.md

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,84 @@
1-
caption.md
1+
HTML \<caption> Tag
22
===
33

4-
欢迎您编辑 <a target="__blank" href="https://github.com/jaywcjlove/html-tutorial/blob/master/docs/tags/caption.md">docs/tags/caption.md</a> 文件,共建 HTML Tutorial 文档。
4+
## 示例
5+
6+
带标题的表格:
7+
8+
```html idoc:preview
9+
<table>
10+
  <caption>Monthly savings</caption>
11+
  <tr>
12+
    <th>Month</th>
13+
    <th>Savings</th>
14+
  </tr>
15+
  <tr>
16+
    <td>January</td>
17+
    <td>$100</td>
18+
  </tr>
19+
</table>
20+
```
21+
22+
## 定义和用法
23+
24+
`<caption>` 标签定义了一个表格标题。
25+
26+
`<caption>` 标记必须紧跟在 [\<table>](./table.md) 标记之后。
27+
28+
**提示:** 默认情况下,表格标题将在表格上方居中对齐。 但是,CSS 属性 `text-align``caption-side` 可用于对齐和放置标题。
29+
30+
## 浏览器支持
31+
32+
| Element | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
33+
| --------- | --- | --- | --- | --- | --- |
34+
| \<caption> | Yes | Yes | Yes | Yes | Yes |
35+
36+
## 全局属性
37+
38+
`<button>` 标签支持 HTML 中的[全局属性](../reference/standardattributes.md)
39+
40+
## 事件属性
41+
42+
`<button>` 标签支持 HTML 中的[事件属性](../reference/eventattributes.md)
43+
44+
## 更多示例
45+
46+
位置表标题(使用 CSS):
47+
48+
```html idoc:preview
49+
<table>
50+
  <caption style="text-align:right">My savings</caption>
51+
  <tr>
52+
    <th>Month</th>
53+
    <th>Savings</th>
54+
  </tr>
55+
  <tr>
56+
    <td>January</td>
57+
    <td>$100</td>
58+
  </tr>
59+
</table>
60+
<br>
61+
62+
<table>
63+
  <caption style="caption-side:bottom">My savings</caption>
64+
  <tr>
65+
    <th>Month</th>
66+
    <th>Savings</th>
67+
  </tr>
68+
  <tr>
69+
    <td>January</td>
70+
    <td>$100</td>
71+
  </tr>
72+
</table>
73+
```
74+
75+
## 默认 CSS 设置
76+
77+
大多数浏览器将显示具有以下默认值的 `<caption>` 元素:
78+
79+
```css
80+
caption {
81+
  display: table-caption;
82+
  text-align: center;
83+
}
84+
```

0 commit comments

Comments
 (0)