出栏布局
正文保持适合阅读的栏宽,图文块或横幅可适度加宽或延伸至页面边缘。
本页内容
出栏布局将正文栏居中放在可用空间内,并将行长控制在适合阅读的范围。图片、表格或横幅可以比正文栏略宽,也可以一直延伸到两侧边缘。这种布局适合长文、更新日志或故事,既让正文保持舒适的行长,也给其他内容留出更多空间。
子元素默认排在正文栏内。需要出栏的元素才使用 breakout-wide 或 breakout-full。布局本身不绘制表面,通栏横幅的外观由工具类或组件提供。
出栏布局
<article class="breakout py-2xl bg-surface-base fg-text-body text-md leading-lg"> <header class="flex flex-col gap-xs"> <p class="eyebrow">Changelog · 12 November</p> <h1 class="heading heading-2xl">Faster cold builds, and comments on previews</h1> <p class="lead"> Dependency caches are now restored before the install step, and anyone with the link to a preview can leave a comment on it. </p> </header> <p> A cold build is one that starts with nothing: a new branch, a cleared cache, a project that has not built in a week. Until this release it downloaded every dependency again before it could restore anything, which made the first build of a branch the slowest one, and the one people waited for most. </p> <figure class="figure breakout-wide"> <img class="figure-media" src="/demo/harbor.svg" alt="A wooden jetty running out over calm water" style="--figure-ratio: 21 / 9"> <figcaption class="figure-caption"> The cache now waits at the end of the jetty, not the start: it is there before the install begins. </figcaption> </figure> <h2 class="heading heading-lg mt-md">Caches before the install</h2> <p> The cache of a project is now keyed by its lockfile and restored before the install step runs. The install finds what it needs already in place and only fetches what changed. A branch that changes no dependency builds as fast as the one it came from. </p> <div class="breakout breakout-full py-xl bg-surface-tray"> <dl class="auto-grid" style="--auto-grid-min: 9rem"> <div class="stat"> <dt class="stat-label">Cold builds</dt> <dd class="stat-row m(0)"> <span class="stat-value">38s</span><span class="stat-delta">21% faster</span> </dd> </div> <div class="stat"> <dt class="stat-label">Installs skipped</dt> <dd class="stat-row m(0)"><span class="stat-value">64%</span></dd> </div> <div class="stat"> <dt class="stat-label">Data fetched</dt> <dd class="stat-row m(0)"> <span class="stat-value">1.9 GB</span><span class="stat-delta">48% less</span> </dd> </div> </dl> </div> <h2 class="heading heading-lg mt-md">Comments on previews</h2> <p> Anyone with the link to a preview can now leave a comment on it, pinned to the place they mean. Comments are kept with the deploy, so they are still there when someone opens the same preview next week, and they are listed on the pull request. </p> <div class="scroll-area scroll-area-inline breakout-wide" tabindex="0" role="region" aria-label="Who can comment, by plan"> <table class="table"> <thead> <tr class="table-row"> <th class="table-heading" scope="col">Plan</th> <th class="table-heading" scope="col">Who can comment</th> <th class="table-heading" scope="col">Kept for</th> <th class="table-heading table-numeric" scope="col">Previews</th> </tr> </thead> <tbody> <tr class="table-row"> <th class="table-cell table-primary" scope="row">Free</th> <td class="table-cell">Members of the team</td> <td class="table-cell">30 days</td> <td class="table-cell table-numeric">10</td> </tr> <tr class="table-row"> <th class="table-cell table-primary" scope="row">Pro</th> <td class="table-cell">Anyone with the link</td> <td class="table-cell">One year</td> <td class="table-cell table-numeric">Unlimited</td> </tr> </tbody> </table> </div> <p>Both changes are on for every project today. There is nothing to turn on.</p></article><article className="breakout py-2xl bg-surface-base fg-text-body text-md leading-lg"> <header className="flex flex-col gap-xs"> <p className="eyebrow">Changelog · 12 November</p> <h1 className="heading heading-2xl">Faster cold builds, and comments on previews</h1> <p className="lead"> Dependency caches are now restored before the install step, and anyone with the link to a preview can leave a comment on it. </p> </header> <p> A cold build is one that starts with nothing: a new branch, a cleared cache, a project that has not built in a week. Until this release it downloaded every dependency again before it could restore anything, which made the first build of a branch the slowest one, and the one people waited for most. </p> <figure className="figure breakout-wide"> <img className="figure-media" src="/demo/harbor.svg" alt="A wooden jetty running out over calm water" style={{ '--figure-ratio': '21 / 9' } as React.CSSProperties} /> <figcaption className="figure-caption"> The cache now waits at the end of the jetty, not the start: it is there before the install begins. </figcaption> </figure> <h2 className="heading heading-lg mt-md">Caches before the install</h2> <p> The cache of a project is now keyed by its lockfile and restored before the install step runs. The install finds what it needs already in place and only fetches what changed. A branch that changes no dependency builds as fast as the one it came from. </p> <div className="breakout breakout-full py-xl bg-surface-tray"> <dl className="auto-grid" style={{ '--auto-grid-min': '9rem' } as React.CSSProperties}> <div className="stat"> <dt className="stat-label">Cold builds</dt> <dd className="stat-row m(0)"> <span className="stat-value">38s</span><span className="stat-delta">21% faster</span> </dd> </div> <div className="stat"> <dt className="stat-label">Installs skipped</dt> <dd className="stat-row m(0)"><span className="stat-value">64%</span></dd> </div> <div className="stat"> <dt className="stat-label">Data fetched</dt> <dd className="stat-row m(0)"> <span className="stat-value">1.9 GB</span><span className="stat-delta">48% less</span> </dd> </div> </dl> </div> <h2 className="heading heading-lg mt-md">Comments on previews</h2> <p> Anyone with the link to a preview can now leave a comment on it, pinned to the place they mean. Comments are kept with the deploy, so they are still there when someone opens the same preview next week, and they are listed on the pull request. </p> <div className="scroll-area scroll-area-inline breakout-wide" tabIndex={0} role="region" aria-label="Who can comment, by plan"> <table className="table"> <thead> <tr className="table-row"> <th className="table-heading" scope="col">Plan</th> <th className="table-heading" scope="col">Who can comment</th> <th className="table-heading" scope="col">Kept for</th> <th className="table-heading table-numeric" scope="col">Previews</th> </tr> </thead> <tbody> <tr className="table-row"> <th className="table-cell table-primary" scope="row">Free</th> <td className="table-cell">Members of the team</td> <td className="table-cell">30 days</td> <td className="table-cell table-numeric">10</td> </tr> <tr className="table-row"> <th className="table-cell table-primary" scope="row">Pro</th> <td className="table-cell">Anyone with the link</td> <td className="table-cell">One year</td> <td className="table-cell table-numeric">Unlimited</td> </tr> </tbody> </table> </div> <p>Both changes are on for every project today. There is nothing to turn on.</p></article><article class="breakout py-2xl bg-surface-base fg-text-body text-md leading-lg"> <header class="flex flex-col gap-xs"> <p class="eyebrow">Changelog · 12 November</p> <h1 class="heading heading-2xl">Faster cold builds, and comments on previews</h1> <p class="lead"> Dependency caches are now restored before the install step, and anyone with the link to a preview can leave a comment on it. </p> </header> <p> A cold build is one that starts with nothing: a new branch, a cleared cache, a project that has not built in a week. Until this release it downloaded every dependency again before it could restore anything, which made the first build of a branch the slowest one, and the one people waited for most. </p> <figure class="figure breakout-wide"> <img class="figure-media" src="/demo/harbor.svg" alt="A wooden jetty running out over calm water" style="--figure-ratio: 21 / 9"> <figcaption class="figure-caption"> The cache now waits at the end of the jetty, not the start: it is there before the install begins. </figcaption> </figure> <h2 class="heading heading-lg mt-md">Caches before the install</h2> <p> The cache of a project is now keyed by its lockfile and restored before the install step runs. The install finds what it needs already in place and only fetches what changed. A branch that changes no dependency builds as fast as the one it came from. </p> <div class="breakout breakout-full py-xl bg-surface-tray"> <dl class="auto-grid" style="--auto-grid-min: 9rem"> <div class="stat"> <dt class="stat-label">Cold builds</dt> <dd class="stat-row m(0)"> <span class="stat-value">38s</span><span class="stat-delta">21% faster</span> </dd> </div> <div class="stat"> <dt class="stat-label">Installs skipped</dt> <dd class="stat-row m(0)"><span class="stat-value">64%</span></dd> </div> <div class="stat"> <dt class="stat-label">Data fetched</dt> <dd class="stat-row m(0)"> <span class="stat-value">1.9 GB</span><span class="stat-delta">48% less</span> </dd> </div> </dl> </div> <h2 class="heading heading-lg mt-md">Comments on previews</h2> <p> Anyone with the link to a preview can now leave a comment on it, pinned to the place they mean. Comments are kept with the deploy, so they are still there when someone opens the same preview next week, and they are listed on the pull request. </p> <div class="scroll-area scroll-area-inline breakout-wide" tabindex="0" role="region" aria-label="Who can comment, by plan"> <table class="table"> <thead> <tr class="table-row"> <th class="table-heading" scope="col">Plan</th> <th class="table-heading" scope="col">Who can comment</th> <th class="table-heading" scope="col">Kept for</th> <th class="table-heading table-numeric" scope="col">Previews</th> </tr> </thead> <tbody> <tr class="table-row"> <th class="table-cell table-primary" scope="row">Free</th> <td class="table-cell">Members of the team</td> <td class="table-cell">30 days</td> <td class="table-cell table-numeric">10</td> </tr> <tr class="table-row"> <th class="table-cell table-primary" scope="row">Pro</th> <td class="table-cell">Anyone with the link</td> <td class="table-cell">One year</td> <td class="table-cell table-numeric">Unlimited</td> </tr> </tbody> </table> </div> <p>Both changes are on for every project today. There is nothing to turn on.</p></article><template> <article class="breakout py-2xl bg-surface-base fg-text-body text-md leading-lg"> <header class="flex flex-col gap-xs"> <p class="eyebrow">Changelog · 12 November</p> <h1 class="heading heading-2xl">Faster cold builds, and comments on previews</h1> <p class="lead"> Dependency caches are now restored before the install step, and anyone with the link to a preview can leave a comment on it. </p> </header> <p> A cold build is one that starts with nothing: a new branch, a cleared cache, a project that has not built in a week. Until this release it downloaded every dependency again before it could restore anything, which made the first build of a branch the slowest one, and the one people waited for most. </p> <figure class="figure breakout-wide"> <img class="figure-media" src="/demo/harbor.svg" alt="A wooden jetty running out over calm water" style="--figure-ratio: 21 / 9"> <figcaption class="figure-caption"> The cache now waits at the end of the jetty, not the start: it is there before the install begins. </figcaption> </figure> <h2 class="heading heading-lg mt-md">Caches before the install</h2> <p> The cache of a project is now keyed by its lockfile and restored before the install step runs. The install finds what it needs already in place and only fetches what changed. A branch that changes no dependency builds as fast as the one it came from. </p> <div class="breakout breakout-full py-xl bg-surface-tray"> <dl class="auto-grid" style="--auto-grid-min: 9rem"> <div class="stat"> <dt class="stat-label">Cold builds</dt> <dd class="stat-row m(0)"> <span class="stat-value">38s</span><span class="stat-delta">21% faster</span> </dd> </div> <div class="stat"> <dt class="stat-label">Installs skipped</dt> <dd class="stat-row m(0)"><span class="stat-value">64%</span></dd> </div> <div class="stat"> <dt class="stat-label">Data fetched</dt> <dd class="stat-row m(0)"> <span class="stat-value">1.9 GB</span><span class="stat-delta">48% less</span> </dd> </div> </dl> </div> <h2 class="heading heading-lg mt-md">Comments on previews</h2> <p> Anyone with the link to a preview can now leave a comment on it, pinned to the place they mean. Comments are kept with the deploy, so they are still there when someone opens the same preview next week, and they are listed on the pull request. </p> <div class="scroll-area scroll-area-inline breakout-wide" tabindex="0" role="region" aria-label="Who can comment, by plan"> <table class="table"> <thead> <tr class="table-row"> <th class="table-heading" scope="col">Plan</th> <th class="table-heading" scope="col">Who can comment</th> <th class="table-heading" scope="col">Kept for</th> <th class="table-heading table-numeric" scope="col">Previews</th> </tr> </thead> <tbody> <tr class="table-row"> <th class="table-cell table-primary" scope="row">Free</th> <td class="table-cell">Members of the team</td> <td class="table-cell">30 days</td> <td class="table-cell table-numeric">10</td> </tr> <tr class="table-row"> <th class="table-cell table-primary" scope="row">Pro</th> <td class="table-cell">Anyone with the link</td> <td class="table-cell">One year</td> <td class="table-cell table-numeric">Unlimited</td> </tr> </tbody> </table> </div> <p>Both changes are on for every project today. There is nothing to turn on.</p> </article></template>#布局原理
- 单列网格。 出栏布局只有一列,列宽取
--breakout-measure(默认 40rem)与可用宽度扣除两侧各一个--breakout-gutter后的值中的较小者。这一列居中,所有子元素默认排入其中,无需添加类名。 - 用外边距向栏外延伸。 出栏布局是一个行内尺寸容器。在子元素中,
100cqi是出栏布局的宽度,100%是正文栏的宽度,因此单侧可用空间是两者宽度差的一半。breakout-wide用负外边距占用这部分空间,每侧最多延伸--breakout-wide,并保留边缘留白。breakout-full则占满两侧空间。 - 横幅内的文字与正文栏对齐。 通栏子元素也可以设为
breakout,让自身延伸到两侧边缘,同时把子元素排在与正文栏等宽的一列中。上方示例里,横幅中的数字与前后的正文对齐。 - 用网格行间距统一节奏。 网格中的外边距不会折叠,因此用 1.25rem 的网格行间距分隔子元素。标题用
mt-md让它与前文的距离比与后文的距离略大。 - 宽表格可独立滚动。 表格放在同时应用
scroll-area-inline和breakout-wide的滚动区域内,因此在手机上,表格会在栏内滚动,不会撑宽页面。
#加宽与通栏
子元素能加宽多少,取决于正文栏两侧的可用空间,也就取决于页面宽度。
| 可用宽度 | 正文栏 | breakout-wide | breakout-full |
|---|---|---|---|
| 大于正文栏最大宽度加两侧最大加宽量之和 | 40rem,居中 | 每侧增加 8rem,总宽 56rem | 占满可用宽度 |
| 介于两个阈值之间 | 40rem,居中 | 每侧可延伸至边缘留白处 | 占满可用宽度 |
| 小于正文栏的最大宽度 | 可用宽度扣除两侧留白 | 与正文栏等宽 | 占满可用宽度 |
宽度
<div class="breakout py-lg fg-text-muted text-sm" style="--breakout-measure: 20rem; --breakout-wide: 5rem"> <div class="well flex items-center justify-center h(56)">The column</div> <div class="well flex items-center justify-center h(56) breakout-wide">breakout-wide</div> <div class="well flex items-center justify-center h(56) breakout-full">breakout-full</div> <div class="well flex items-center justify-center h(56)">The column</div></div><div className="breakout py-lg fg-text-muted text-sm" style={{ '--breakout-measure': '20rem', '--breakout-wide': '5rem' } as React.CSSProperties}> <div className="well flex items-center justify-center h(56)">The column</div> <div className="well flex items-center justify-center h(56) breakout-wide">breakout-wide</div> <div className="well flex items-center justify-center h(56) breakout-full">breakout-full</div> <div className="well flex items-center justify-center h(56)">The column</div></div><div class="breakout py-lg fg-text-muted text-sm" style="--breakout-measure: 20rem; --breakout-wide: 5rem"> <div class="well flex items-center justify-center h(56)">The column</div> <div class="well flex items-center justify-center h(56) breakout-wide">breakout-wide</div> <div class="well flex items-center justify-center h(56) breakout-full">breakout-full</div> <div class="well flex items-center justify-center h(56)">The column</div></div><template> <div class="breakout py-lg fg-text-muted text-sm" style="--breakout-measure: 20rem; --breakout-wide: 5rem"> <div class="well flex items-center justify-center h(56)">The column</div> <div class="well flex items-center justify-center h(56) breakout-wide">breakout-wide</div> <div class="well flex items-center justify-center h(56) breakout-full">breakout-full</div> <div class="well flex items-center justify-center h(56)">The column</div> </div></template>--breakout-measure 设定正文栏的最大宽度。40rem 大约能容纳 70 个正文字符。字号较大时可调小此值,主要放代码时可调大。--breakout-wide 设定加宽子元素每侧最多能延伸多远,--breakout-gutter 设定除通栏子元素外,内容与边缘之间至少要保留多少空间。
#通栏横幅
通栏横幅通常在色块或图片上叠放文字,文字仍应留在正文栏内。将横幅本身设为出栏布局。它作为 breakout-full 子元素延伸到两侧边缘,内部的子元素则排在与前后正文等宽的一列中。
<div class="breakout breakout-full py-xl bg-surface-tray"> <p>These words line up with the column above and below the band.</p></div>出栏布局本身不绘制表面,横幅的颜色由工具类 bg-surface-tray 提供。图片要延伸到两侧边缘时,使用带有 --figure-radius: 0 的 breakout-full 图文块,让图片在窗口边缘保持直角。
#何时使用
文章、博客文章、更新日志和指南等以单栏阅读为主的页面适合使用出栏布局。它位于页面框架的主区域中。如果正文栏旁还有导航、目录等区域,可使用文档页,其中的文章栏也可以采用出栏布局。如果所有内容都留在栏内,只需用工具类 max-w(640) mx-auto 限制栏的最大宽度并将其居中,并留出边缘空白。
#无障碍
- 出栏布局只调整宽度,阅读顺序始终遵循标记中的元素顺序。
- 栏宽以 rem 为单位,随读者的文字大小变化。字号增大时,栏也会变宽,每行仍约有 70 个字符。当窗口比栏窄时,栏宽会随窗口收窄,页面无需横向滚动。
- 宽于正文栏的表格放在带有无障碍名称和
tabindex="0"的滚动区域中,以便用键盘滚动。
#类名
| 类名 | 说明 |
|---|---|
breakout | 单列网格居中,最大宽度为 --breakout-measure,两侧各留 --breakout-gutter,子元素间距为 1.25rem。网格是行内尺寸查询容器,不绘制任何视觉样式。 |
breakout-wide | 子元素可在正文栏两侧各向外延伸最多 --breakout-wide,受栏旁可用空间限制,且不得侵入页边留白 |
breakout-full | 延伸至 breakout 两侧边缘的子元素 |
#自定义属性
| 属性 | 默认值 | 说明 |
|---|---|---|
--breakout-measure | 40rem | 正文栏的最大宽度约为 70 个正文字符的宽度。 |
--breakout-wide | 8rem | 较宽的子元素可向栏的两侧各伸出多远 |
--breakout-gutter | 1.5rem | 正文栏及宽幅子元素与边缘之间各自保留的最小间距。 |
#相关内容
- 图文块带边缘处理和图注的图片或视频。
- 标题沿用页面文本色的标题,可搭配上方的引题和下方的导语。
- 表格用细线分隔数据行,支持可排序表头和数值对齐。
- 滚动区域可滚动的区域。对应方向还有内容时,边缘渐隐。
- 引用块将他人的原话单独排版,与自己的文字区分开。
- 布局组合多数布局由四种排列方式组合而成:纵向堆叠、横向换行、两端对齐和居中。