# 卡片

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

您可以调整 [在中号或大号卡片之间切换](#card-size) 并将它们链接到相关资源。

### 卡片示例

<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="/files/a6021be8434dc0c1095ab16e1c6fe33420245627">/files/a6021be8434dc0c1095ab16e1c6fe33420245627</a></td><td><a href="/files/68c23f2f83d6e42aab018b1e0e5b64e28ca1c3bb">/files/68c23f2f83d6e42aab018b1e0e5b64e28ca1c3bb</a></td><td></td><td><a href="/files/68c23f2f83d6e42aab018b1e0e5b64e28ca1c3bb">/files/68c23f2f83d6e42aab018b1e0e5b64e28ca1c3bb</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="/files/4e1ac27986d3a0d698936498621160c5da78b9cb">/files/4e1ac27986d3a0d698936498621160c5da78b9cb</a></td><td></td><td><a href="/files/6f27471f47013917cf9950f8038f9a65c9b81370">/files/6f27471f47013917cf9950f8038f9a65c9b81370</a></td><td><a href="/files/6f27471f47013917cf9950f8038f9a65c9b81370">/files/6f27471f47013917cf9950f8038f9a65c9b81370</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="/files/8d21dbf500173ebc03c5b7d6d5d16c2c4e2bf0e2">/files/8d21dbf500173ebc03c5b7d6d5d16c2c4e2bf0e2</a></td><td></td><td></td><td><a href="/files/aef61fd9bf8c828ade96577bfc9dd8bbbf211332">/files/aef61fd9bf8c828ade96577bfc9dd8bbbf211332</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="/files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="/files/e1df373962dc4830bcb786d7e5cb3cce603367d3" alt="The Options menu icon in GitBook"></picture>。在这里你可以添加目标链接，这样用户点击卡片时就能直接跳转到某个位置。

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

### 添加图片

将鼠标悬停在卡片上并打开其 **选项菜单** <picture><source srcset="/files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="/files/e1df373962dc4830bcb786d7e5cb3cce603367d3" alt="The Options menu icon in GitBook"></picture>。在这里你可以为卡片添加封面图片。或者，直接点击卡片上的 **添加封面图片** 选项。

这将打开 **选择文件** 模态窗口。在这里你可以将新图片拖放到其中，或者使用你之前上传到空间中的图片文件。

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

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

为此，请打开卡片的 **选项菜单** <picture><source srcset="/files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="/files/e1df373962dc4830bcb786d7e5cb3cce603367d3" alt=""></picture> 并选择 **封面** > **编辑封面** > **为深色模式添加封面**。这将打开 **选择文件** 模态窗口，在这里你可以拖放新图片或选择之前上传的图片。

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

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

<figure><img src="/files/337433e1d7852d225db4206957c80896e142972c" alt="A GitBook screenshot showing card images on desktop"><figcaption><p>在桌面端，所有卡片图片都会以横向 16:9 比例显示，而不管其尺寸如何。我们建议使用相同的尺寸以保持一致性。</p></figcaption></figure>

<figure><img src="/files/d5d15fea9b91d3b042535e3b83f67879a643ef5a" alt="A GitBook screenshot showing card images on mobile"><figcaption><p>在移动端，正方形或纵向图片将按左侧所示显示。横向图片将按右侧所示显示。</p></figcaption></figure>

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

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

### 更改卡片大小

你可以通过打开 **选项菜单** <picture><source srcset="/files/QLUQj6waZRiK6FpSqrt6" media="(prefers-color-scheme: dark)"><img src="/files/e1df373962dc4830bcb786d7e5cb3cce603367d3" 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.com/docs/documentation/zh/creating-content/blocks/cards.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
