Files
mintlify[bot] 2995f5d854 docs: note drag-to-resize table columns in the editor (#7322)
Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
2026-09-10 11:05:42 -07:00

209 lines
4.9 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "列表与表格"
description: "使用 Markdown 表格、有序列表、无序列表、嵌套结构和任务列表复选框在文档中呈现结构化数据。"
keywords: ["有序列表", "无序列表", "Markdown 表格", "表格格式"]
---
<div id="lists">
## 列表
</div>
列表遵循官方的 [Markdown 语法](https://www.markdownguide.org/basic-syntax/#lists-1)。
<div id="ordered-list">
### 有序列表
</div>
要创建有序列表,请在每个列表项前加上数字和一个句点。
1. 第一项
2. 第二项
3. 第三项
4. 第四项
```mdx
1. 第一项
2. 第二项
3. 第三项
4. 第四项
```
<div id="unordered-list">
### 无序列表
</div>
要创建无序列表,在列表项前添加连字符(`-`)、星号(`*`)或加号(`+`)。
* 第一项
* 第二项
* 第三项
* 第四项
```mdx
- 第一项
- 第二项
- 第三项
- 第四项
```
<div id="nested-list">
### 嵌套列表
</div>
通过缩进列表项来创建嵌套。
* 第一项
* 第二项
* 附加项
* 附加项
* 第三项
```mdx
- 第一项
- 第二项
- 附加项
- 附加项
- 第三项
```
<div id="task-list">
### 任务列表
</div>
要创建任务列表,在无序列表标记后添加 `[ ]` 表示未勾选的复选框,或添加 `[x]` 表示已勾选的复选框。
- [x] 已完成项
- [ ] 未完成项
```mdx
- [x] 已完成项
- [ ] 未完成项
```
<div id="tables">
## 表格
</div>
表格遵循官方的 [Markdown 语法](https://www.markdownguide.org/extended-syntax/#tables)。
要添加表格,使用三个或更多连字符(`---`)来创建每一列的表头,并使用竖线(`|`)分隔每一列。为兼容起见,还应在每行的两端各添加一个竖线。
| 属性 | 说明 |
| -------- | -------------------------------------- |
| 名称 | 用户全名 |
| 年龄 | 用户填写的年龄 |
| 加入 | 该用户是否已加入社区 |
```mdx
| Property | 说明 |
| -------- | ------------------------------------- |
| Name | 用户全名 |
| Age | 年龄 |
| Joined | 用户是否已加入社区 |
```
<div id="escape-pipe-characters">
### 转义竖线字符
</div>
要在表格单元格中包含字面量竖线字符(`|`),请在其前面加上反斜杠(`\|`)。即使竖线字符出现在行内代码中,也需要转义。否则,竖线会被视为列分隔符,可能在预览或验证时导致解析错误。
| 值 | 说明 |
| ------------- | ------------------------ |
| `read\|write` | 包含字面量竖线的值 |
```mdx
| Value | Description |
| ------------- | --------------------------------- |
| `read\|write` | A value containing a literal pipe |
```
<div id="column-alignment">
### 列对齐
</div>
在分隔行中使用冒号来设置列内容的对齐方式:
| 左对齐 | 居中对齐 | 右对齐 |
| :-- | :--: | --: |
| 左 | 中 | 右 |
| 文本 | 文本 | 文本 |
```mdx
| 左对齐 | 居中对齐 | 右对齐 |
| :----------- | :------------: | ------------: |
| 左对齐 | 居中对齐 | 右对齐 |
| 文本 | 文本 | 文本 |
```
<div id="column-widths">
### 列宽
</div>
Markdown 表格会根据内容自动调整列宽。要控制列宽,请使用 HTML 编写表格,并添加一个为每个 `<col>` 设置宽度的 `<colgroup>` 元素。
在[编辑器](/zh/editor)的可视化模式中,拖动列边框即可调整列宽。编辑器会自动将表格转换为 HTML 并写入 `<colgroup>` 宽度。
当每个 `<col>` 都通过 `width` 属性或内联样式声明宽度时,表格会使用你设置的宽度,并在每列内换行显示过长的内容。如果任何 `<col>` 缺少宽度,Mintlify 会忽略声明的宽度并根据内容调整列宽。超出页面宽度的表格仍然可以水平滚动。
<table>
<colgroup>
<col width="25%" />
<col width="15%" />
<col width="60%" />
</colgroup>
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>string</td>
<td>用户的全名</td>
</tr>
<tr>
<td>age</td>
<td>number</td>
<td>用户报告的年龄</td>
</tr>
</tbody>
</table>
```html
<table>
<colgroup>
<col width="25%" />
<col width="15%" />
<col width="60%" />
</colgroup>
<thead>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>string</td>
<td>Full name of the user</td>
</tr>
<tr>
<td>age</td>
<td>number</td>
<td>Reported age of the user</td>
</tr>
</tbody>
</table>
```