> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/zh/chuang-jian-nei-rong/blocks/cards.md).

# 卡片

使用一组卡片更动态地展示信息——可带图或无图

你可以使用卡片创建视觉上赏心悦目的页面布局，将文本和图片以网格方式组合。它们非常适合构建落地页或以非线性方式展示任何其他内容。

您可以 [在中型卡片和大型卡片之间切换](#changing-the-size-of-cards) 并将它们链接到相关资源。

### 卡片示例

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="image">封面图片</th><th data-hidden data-type="image">封面图片（深色）</th><th data-hidden data-type="image">封面图片（深色）</th><th data-hidden data-card-cover-dark data-type="image">封面图片（深色）</th></tr></thead><tbody><tr><td><strong>GitBook 主页</strong></td><td>访问我们的网站，了解更多关于 GitBook 的信息。</td><td><a href="https://www.gitbook.com/">https://www.gitbook.com/</a></td><td><a href="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-50d99439ff1e20b164b604793fe65e986bdb3d4c%2F25_12_10_cards_3.png?alt=media">25_12_10_cards_3.png</a></td><td><a href="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-d51ff4f65e39b788e09efcccf617cff7514dfc04%2F25_12_10_cards_2.png?alt=media">25_12_10_cards_2.png</a></td><td></td><td><a href="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-d51ff4f65e39b788e09efcccf617cff7514dfc04%2F25_12_10_cards_2.png?alt=media">25_12_10_cards_2.png</a></td></tr><tr><td><strong>开发者文档</strong></td><td>构建你自己的 GitBook 集成。</td><td><a href="https://developer.gitbook.com/">https://developer.gitbook.com/</a></td><td><a href="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-750f34dc35be306ea8c19106f346a8253df28420%2F25_12_10_cards_1.png?alt=media">25_12_10_cards_1.png</a></td><td></td><td><a href="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-175e39a8623f4a66cca9c54fdeb7f7e55342c39b%2F25_12_10_cards.png?alt=media">25_12_10_cards.png</a></td><td><a href="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-175e39a8623f4a66cca9c54fdeb7f7e55342c39b%2F25_12_10_cards.png?alt=media">25_12_10_cards.png</a></td></tr><tr><td><strong>注册 GitBook</strong></td><td>免费开始使用。</td><td><a href="https://app.gitbook.com/join">https://app.gitbook.com/join</a></td><td><a href="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-89a5dd251f6d5434e441f09add65eaff2638b95d%2F25_12_10_cards_5.png?alt=media">25_12_10_cards_5.png</a></td><td></td><td></td><td><a href="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-918fb295e6669005661e2d16527566a9bdf677a8%2F25_12_10_cards_4.png?alt=media">25_12_10_cards_4.png</a></td></tr></tbody></table>

### 添加链接 <a href="#adding-links-and-images-to-your-cards" id="adding-links-and-images-to-your-cards"></a>

将鼠标悬停在卡片上，然后打开其 **选项菜单** <picture><source srcset="broken://files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-23f3e8f05326b0d239d32d28bba99c1d46f204f7%2F25_01_10_options_light.svg?alt=media" alt="The Options menu icon in GitBook"></picture>。你可以在此添加目标链接，这样读者点击卡片时就能直接跳转到相应位置。

{% hint style="success" %}
创建卡片时，我们建议使用 **目标链接，而不是超链接**。使用目标链接后，读者可以点击卡片的任意位置来访问所链接的网址。
{% endhint %}

### 添加图片

将鼠标悬停在卡片上，然后打开其 **选项菜单** <picture><source srcset="broken://files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-23f3e8f05326b0d239d32d28bba99c1d46f204f7%2F25_01_10_options_light.svg?alt=media" alt="The Options menu icon in GitBook"></picture>。在这里，您可以为卡片添加封面图片。或者，点击卡片本身上的 **添加封面图片** 选项。

这将打开 **选择文件** 模态窗口。你可以将新图片拖放到此处，也可以使用之前上传到所在分区的图片文件。

#### 为深色模式添加图片

你也可以添加仅在深色模式下显示的封面图片。

为此，请打开卡片的 **选项菜单** <picture><source srcset="broken://files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-23f3e8f05326b0d239d32d28bba99c1d46f204f7%2F25_01_10_options_light.svg?alt=media" alt=""></picture> 并选择 **封面** > **编辑封面** > **添加深色模式封面**。这将打开 **选择文件** 模态窗口，你可以在其中拖放新图片，或选择之前上传的图片。

#### 选择合适的图片尺寸

GitBook 会在桌面端和移动端自动将横向图片裁剪为 16:9 比例。如果你上传的图片是竖向或 1:1 比例，它们在桌面端会被裁剪为 16:9，在移动端则显示为方形或竖向。

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-accc608138df1f2b65e1bb5f52591ed1e2fae500%2F26_01_06_cards_desktop%402x.png?alt=media" alt="A GitBook screenshot showing card images on desktop"><figcaption><p>在桌面端，无论尺寸如何，所有卡片图片都会以横向 16:9 比例显示。为保持一致性，我们建议使用相同的尺寸。</p></figcaption></figure>

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-a07138ec9e654e4a0cf94d5d076b233439187d28%2F26_01_06_cards_mobile%402x.png?alt=media" alt="A GitBook screenshot showing card images on mobile"><figcaption><p>在移动端，方形或竖向图片会如左侧所示显示。横向图片会如右侧所示显示。</p></figcaption></figure>

为保持桌面端和移动端的一致性，我们建议以 16:9 格式上传所有卡片图片（例如 1920px x 1080px）。

如果你希望卡片根据屏幕大小自适应布局，我们建议上传 1:1 比例的图片，并将图片内容居中。

### 更改卡片大小

你可以打开卡片块左侧的 **选项菜单** <picture><source srcset="broken://files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-23f3e8f05326b0d239d32d28bba99c1d46f204f7%2F25_01_10_options_light.svg?alt=media" alt="The Options menu icon in GitBook"></picture> 来选择卡片大小。 **中型** 选项会在同一行横向排列三张卡片，而 **大型** 选项会在每行显示两张较大的卡片。

### Markdown 表示

```markdown
<table data-view="cards">
  <thead>
    <tr>
      <th></th>
      <th></th>
      <th data-hidden data-card-target data-type="content-ref"></th>
      <th data-hidden data-card-cover data-type="files"></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>示例标题 1</strong></td>
      <td>示例描述 1。</td>
      <td><a href="https://example.com">https://example.com</a></td>
      <td><a href="https://example.com/image1.svg">example_image1.svg</a></td>
    </tr>
    <tr>
      <td><strong>示例标题 2</strong></td>
      <td>示例描述 2。</td>
      <td><a href="https://example.com">https://example.com</a></td>
      <td><a href="https://example.com/image2.svg">example_image2.svg</a></td>
    </tr>
    <tr>
      <td><strong>示例标题 3</strong></td>
      <td>示例描述 3。</td>
      <td><a href="https://example.com">https://example.com</a></td>
      <td><a href="https://example.com/image3.svg">example_image3.svg</a></td>
    </tr>
  </tbody>
</table>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/documentation/zh/chuang-jian-nei-rong/blocks/cards.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
