Bento 版面
在同一容器內排列幾種尺寸的區塊,欄數隨可用空間調整。
本頁內容
Bento 版面把幾個不同尺寸的區塊排進同一個容器。展示產品功能或個人檔案的重點時,可以放一個大區塊,旁邊放一個高區塊,再用幾個小區塊搭配。Bento 只負責版面配置,本身不繪製背景。各區塊由卡片、面板及其中的內容組成。
Bento 會決定欄數以及各區塊能跨幾欄,兩者都以 Bento 本身的可用寬度為準,與檢視區寬度無關。從 48rem 起為四欄,從 28rem 起為兩欄,低於 28rem 則為一欄。寬版 Bento 中跨兩欄的區塊,在兩欄版面會占滿整列,在單欄版面則只占一格。同一份標記在桌面上可交錯排列,在手機上則依序排成一欄。
Bento 版面
<section class="flex flex-col gap-xl p-xl bg-surface-base fg-text-body text-sm" aria-labelledby="bento-title"> <header class="flex flex-col gap-xs max-w(560)"> <p class="eyebrow">Platform</p> <h2 class="heading heading-xl" id="bento-title">Everything a deploy needs</h2> </header> <div class="bento"> <article class="card card-split bento-large"> <img class="card-media" src="/demo/moonstone.svg" alt> <header class="card-header"> <h3 class="card-title">Live at the edge</h3> <p class="card-description"> Every push is served from 14 regions before the review is done. </p> </header> <p class="card-body"> Static files, functions and images are cached where the reader is, and purged the moment a deploy replaces them. </p> <footer class="card-footer"><a class="btn btn-sm" href="#regions">See the regions</a></footer> </article> <article class="card bento-tall"> <header class="card-header"> <h3 class="card-title">Reviewed together</h3> <p class="card-description">Comments land on the preview, beside what they are about.</p> </header> <div class="card-body flex flex-col gap-sm"> <div class="avatar-group" role="group" aria-label="Ada Lovelace, Alan Turing, Grace Hopper and 5 others"> <span class="avatar avatar-sm"> <img class="avatar-image" src="/demo/portrait-1.svg" alt> </span> <span class="avatar avatar-sm"> <img class="avatar-image" src="/demo/portrait-2.svg" alt> </span> <span class="avatar avatar-sm"> <img class="avatar-image" src="/demo/portrait-3.svg" alt> </span> <span class="avatar avatar-sm" aria-hidden="true">+5</span> </div> <p class="m(0)"> Eight people left 23 comments on this week's previews. Four are still open. </p> </div> <footer class="card-footer"><a class="btn btn-sm" href="#comments">Open comments</a></footer> </article> <article class="card"> <div class="stat"> <p class="stat-label">Cold builds</p> <div class="stat-row"> <p class="stat-value">38s</p> <p class="stat-delta">21% faster</p> </div> <p class="stat-description">Caches are restored before the install.</p> </div> </article> <article class="card"> <header class="card-header"> <h3 class="card-title">Rollbacks</h3> <p class="card-description">Any deploy is one click away, and so is the one before it.</p> </header> </article> <article class="card bento-wide"> <header class="card-header"> <h3 class="card-title">Builds this week</h3> <p class="card-description">Thursday so far</p> </header> <figure class="chart chart-quiet" style="--chart-height: 4.5rem"> <div class="chart-body"> <svg class="chart-plot" role="list" aria-label="Builds per day, this week"> <g aria-hidden="true"> <line class="chart-grid chart-grid-base" x1="0" y1="100%" x2="100%" y2="100%" /> <line class="chart-grid" x1="0" y1="75%" x2="100%" y2="75%" /> <line class="chart-grid" x1="0" y1="50%" x2="100%" y2="50%" /> <line class="chart-grid" x1="0" y1="25%" x2="100%" y2="25%" /> <line class="chart-grid" x1="0" y1="0%" x2="100%" y2="0%" /> <text class="chart-tick chart-tick-x" x="7.143%" y="100%">Mon</text> <text class="chart-tick chart-tick-x" x="21.429%" y="100%">Tue</text> <text class="chart-tick chart-tick-x" x="35.714%" y="100%">Wed</text> <text class="chart-tick chart-tick-x" x="50%" y="100%">Thu</text> <text class="chart-tick chart-tick-x" x="64.286%" y="100%">Fri</text> <text class="chart-tick chart-tick-x" x="78.571%" y="100%">Sat</text> <text class="chart-tick chart-tick-x" x="92.857%" y="100%">Sun</text> </g> <g class="chart-point" role="listitem" aria-label="Mon: 42"> <rect class="chart-hit" x="0%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="2.714%" y="47.5%" width="8.857%" height="52.5%" /> </g> <g class="chart-point" role="listitem" aria-label="Tue: 58"> <rect class="chart-hit" x="14.286%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="17%" y="27.5%" width="8.857%" height="72.5%" /> </g> <g class="chart-point" role="listitem" aria-label="Wed: 36"> <rect class="chart-hit" x="28.571%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="31.286%" y="55%" width="8.857%" height="45%" /> </g> <g class="chart-point" role="listitem" aria-label="Thu: 71" aria-current="true"> <rect class="chart-hit" x="42.857%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="45.571%" y="11.25%" width="8.857%" height="88.75%" /> </g> <g class="chart-point" role="listitem" aria-label="Fri: 0"> <rect class="chart-hit" x="57.143%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="59.857%" y="99.4%" width="8.857%" height="0.6%" /> </g> <g class="chart-point" role="listitem" aria-label="Sat: 0"> <rect class="chart-hit" x="71.429%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="74.143%" y="99.4%" width="8.857%" height="0.6%" /> </g> <g class="chart-point" role="listitem" aria-label="Sun: 0"> <rect class="chart-hit" x="85.714%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="88.429%" y="99.4%" width="8.857%" height="0.6%" /> </g> </svg> </div> </figure> </article> <article class="sheet sheet-inverse bento-wide flex flex-col justify-between gap-md p(20)"> <div class="flex flex-col gap-3xs"> <h3 class="heading heading-sm fg-text-inverse">Start on the free plan</h3> <p class="m(0)">Three projects and every feature above. No card needed.</p> </div> <div class="flex"><a class="btn btn-sm" href="#start">Create a project</a></div> </article> </div></section><section className="flex flex-col gap-xl p-xl bg-surface-base fg-text-body text-sm" aria-labelledby="bento-title"> <header className="flex flex-col gap-xs max-w(560)"> <p className="eyebrow">Platform</p> <h2 className="heading heading-xl" id="bento-title">Everything a deploy needs</h2> </header> <div className="bento"> <article className="card card-split bento-large"> <img className="card-media" src="/demo/moonstone.svg" alt="" /> <header className="card-header"> <h3 className="card-title">Live at the edge</h3> <p className="card-description"> Every push is served from 14 regions before the review is done. </p> </header> <p className="card-body"> Static files, functions and images are cached where the reader is, and purged the moment a deploy replaces them. </p> <footer className="card-footer"> <a className="btn btn-sm" href="#regions">See the regions</a> </footer> </article> <article className="card bento-tall"> <header className="card-header"> <h3 className="card-title">Reviewed together</h3> <p className="card-description"> Comments land on the preview, beside what they are about. </p> </header> <div className="card-body flex flex-col gap-sm"> <div className="avatar-group" role="group" aria-label="Ada Lovelace, Alan Turing, Grace Hopper and 5 others"> <span className="avatar avatar-sm"> <img className="avatar-image" src="/demo/portrait-1.svg" alt="" /> </span> <span className="avatar avatar-sm"> <img className="avatar-image" src="/demo/portrait-2.svg" alt="" /> </span> <span className="avatar avatar-sm"> <img className="avatar-image" src="/demo/portrait-3.svg" alt="" /> </span> <span className="avatar avatar-sm" aria-hidden="true">+5</span> </div> <p className="m(0)"> Eight people left 23 comments on this week's previews. Four are still open. </p> </div> <footer className="card-footer"> <a className="btn btn-sm" href="#comments">Open comments</a> </footer> </article> <article className="card"> <div className="stat"> <p className="stat-label">Cold builds</p> <div className="stat-row"> <p className="stat-value">38s</p> <p className="stat-delta">21% faster</p> </div> <p className="stat-description">Caches are restored before the install.</p> </div> </article> <article className="card"> <header className="card-header"> <h3 className="card-title">Rollbacks</h3> <p className="card-description"> Any deploy is one click away, and so is the one before it. </p> </header> </article> <article className="card bento-wide"> <header className="card-header"> <h3 className="card-title">Builds this week</h3> <p className="card-description">Thursday so far</p> </header> <figure className="chart chart-quiet" style={{ '--chart-height': '4.5rem' } as React.CSSProperties}> <div className="chart-body"> <svg className="chart-plot" role="list" aria-label="Builds per day, this week"> <g aria-hidden="true"> <line className="chart-grid chart-grid-base" x1="0" y1="100%" x2="100%" y2="100%" /> <line className="chart-grid" x1="0" y1="75%" x2="100%" y2="75%" /> <line className="chart-grid" x1="0" y1="50%" x2="100%" y2="50%" /> <line className="chart-grid" x1="0" y1="25%" x2="100%" y2="25%" /> <line className="chart-grid" x1="0" y1="0%" x2="100%" y2="0%" /> <text className="chart-tick chart-tick-x" x="7.143%" y="100%">Mon</text> <text className="chart-tick chart-tick-x" x="21.429%" y="100%">Tue</text> <text className="chart-tick chart-tick-x" x="35.714%" y="100%">Wed</text> <text className="chart-tick chart-tick-x" x="50%" y="100%">Thu</text> <text className="chart-tick chart-tick-x" x="64.286%" y="100%">Fri</text> <text className="chart-tick chart-tick-x" x="78.571%" y="100%">Sat</text> <text className="chart-tick chart-tick-x" x="92.857%" y="100%">Sun</text> </g> <g className="chart-point" role="listitem" aria-label="Mon: 42"> <rect className="chart-hit" x="0%" y="0" width="14.286%" height="100%" /> <rect className="chart-bar" x="2.714%" y="47.5%" width="8.857%" height="52.5%" /> </g> <g className="chart-point" role="listitem" aria-label="Tue: 58"> <rect className="chart-hit" x="14.286%" y="0" width="14.286%" height="100%" /> <rect className="chart-bar" x="17%" y="27.5%" width="8.857%" height="72.5%" /> </g> <g className="chart-point" role="listitem" aria-label="Wed: 36"> <rect className="chart-hit" x="28.571%" y="0" width="14.286%" height="100%" /> <rect className="chart-bar" x="31.286%" y="55%" width="8.857%" height="45%" /> </g> <g className="chart-point" role="listitem" aria-label="Thu: 71" aria-current="true"> <rect className="chart-hit" x="42.857%" y="0" width="14.286%" height="100%" /> <rect className="chart-bar" x="45.571%" y="11.25%" width="8.857%" height="88.75%" /> </g> <g className="chart-point" role="listitem" aria-label="Fri: 0"> <rect className="chart-hit" x="57.143%" y="0" width="14.286%" height="100%" /> <rect className="chart-bar" x="59.857%" y="99.4%" width="8.857%" height="0.6%" /> </g> <g className="chart-point" role="listitem" aria-label="Sat: 0"> <rect className="chart-hit" x="71.429%" y="0" width="14.286%" height="100%" /> <rect className="chart-bar" x="74.143%" y="99.4%" width="8.857%" height="0.6%" /> </g> <g className="chart-point" role="listitem" aria-label="Sun: 0"> <rect className="chart-hit" x="85.714%" y="0" width="14.286%" height="100%" /> <rect className="chart-bar" x="88.429%" y="99.4%" width="8.857%" height="0.6%" /> </g> </svg> </div> </figure> </article> <article className="sheet sheet-inverse bento-wide flex flex-col justify-between gap-md p(20)"> <div className="flex flex-col gap-3xs"> <h3 className="heading heading-sm fg-text-inverse">Start on the free plan</h3> <p className="m(0)">Three projects and every feature above. No card needed.</p> </div> <div className="flex"><a className="btn btn-sm" href="#start">Create a project</a></div> </article> </div></section><section class="flex flex-col gap-xl p-xl bg-surface-base fg-text-body text-sm" aria-labelledby="bento-title"> <header class="flex flex-col gap-xs max-w(560)"> <p class="eyebrow">Platform</p> <h2 class="heading heading-xl" id="bento-title">Everything a deploy needs</h2> </header> <div class="bento"> <article class="card card-split bento-large"> <img class="card-media" src="/demo/moonstone.svg" alt> <header class="card-header"> <h3 class="card-title">Live at the edge</h3> <p class="card-description"> Every push is served from 14 regions before the review is done. </p> </header> <p class="card-body"> Static files, functions and images are cached where the reader is, and purged the moment a deploy replaces them. </p> <footer class="card-footer"><a class="btn btn-sm" href="#regions">See the regions</a></footer> </article> <article class="card bento-tall"> <header class="card-header"> <h3 class="card-title">Reviewed together</h3> <p class="card-description">Comments land on the preview, beside what they are about.</p> </header> <div class="card-body flex flex-col gap-sm"> <div class="avatar-group" role="group" aria-label="Ada Lovelace, Alan Turing, Grace Hopper and 5 others"> <span class="avatar avatar-sm"> <img class="avatar-image" src="/demo/portrait-1.svg" alt> </span> <span class="avatar avatar-sm"> <img class="avatar-image" src="/demo/portrait-2.svg" alt> </span> <span class="avatar avatar-sm"> <img class="avatar-image" src="/demo/portrait-3.svg" alt> </span> <span class="avatar avatar-sm" aria-hidden="true">+5</span> </div> <p class="m(0)"> Eight people left 23 comments on this week's previews. Four are still open. </p> </div> <footer class="card-footer"><a class="btn btn-sm" href="#comments">Open comments</a></footer> </article> <article class="card"> <div class="stat"> <p class="stat-label">Cold builds</p> <div class="stat-row"> <p class="stat-value">38s</p> <p class="stat-delta">21% faster</p> </div> <p class="stat-description">Caches are restored before the install.</p> </div> </article> <article class="card"> <header class="card-header"> <h3 class="card-title">Rollbacks</h3> <p class="card-description">Any deploy is one click away, and so is the one before it.</p> </header> </article> <article class="card bento-wide"> <header class="card-header"> <h3 class="card-title">Builds this week</h3> <p class="card-description">Thursday so far</p> </header> <figure class="chart chart-quiet" style="--chart-height: 4.5rem"> <div class="chart-body"> <svg class="chart-plot" role="list" aria-label="Builds per day, this week"> <g aria-hidden="true"> <line class="chart-grid chart-grid-base" x1="0" y1="100%" x2="100%" y2="100%" /> <line class="chart-grid" x1="0" y1="75%" x2="100%" y2="75%" /> <line class="chart-grid" x1="0" y1="50%" x2="100%" y2="50%" /> <line class="chart-grid" x1="0" y1="25%" x2="100%" y2="25%" /> <line class="chart-grid" x1="0" y1="0%" x2="100%" y2="0%" /> <text class="chart-tick chart-tick-x" x="7.143%" y="100%">Mon</text> <text class="chart-tick chart-tick-x" x="21.429%" y="100%">Tue</text> <text class="chart-tick chart-tick-x" x="35.714%" y="100%">Wed</text> <text class="chart-tick chart-tick-x" x="50%" y="100%">Thu</text> <text class="chart-tick chart-tick-x" x="64.286%" y="100%">Fri</text> <text class="chart-tick chart-tick-x" x="78.571%" y="100%">Sat</text> <text class="chart-tick chart-tick-x" x="92.857%" y="100%">Sun</text> </g> <g class="chart-point" role="listitem" aria-label="Mon: 42"> <rect class="chart-hit" x="0%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="2.714%" y="47.5%" width="8.857%" height="52.5%" /> </g> <g class="chart-point" role="listitem" aria-label="Tue: 58"> <rect class="chart-hit" x="14.286%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="17%" y="27.5%" width="8.857%" height="72.5%" /> </g> <g class="chart-point" role="listitem" aria-label="Wed: 36"> <rect class="chart-hit" x="28.571%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="31.286%" y="55%" width="8.857%" height="45%" /> </g> <g class="chart-point" role="listitem" aria-label="Thu: 71" aria-current="true"> <rect class="chart-hit" x="42.857%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="45.571%" y="11.25%" width="8.857%" height="88.75%" /> </g> <g class="chart-point" role="listitem" aria-label="Fri: 0"> <rect class="chart-hit" x="57.143%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="59.857%" y="99.4%" width="8.857%" height="0.6%" /> </g> <g class="chart-point" role="listitem" aria-label="Sat: 0"> <rect class="chart-hit" x="71.429%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="74.143%" y="99.4%" width="8.857%" height="0.6%" /> </g> <g class="chart-point" role="listitem" aria-label="Sun: 0"> <rect class="chart-hit" x="85.714%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="88.429%" y="99.4%" width="8.857%" height="0.6%" /> </g> </svg> </div> </figure> </article> <article class="sheet sheet-inverse bento-wide flex flex-col justify-between gap-md p(20)"> <div class="flex flex-col gap-3xs"> <h3 class="heading heading-sm fg-text-inverse">Start on the free plan</h3> <p class="m(0)">Three projects and every feature above. No card needed.</p> </div> <div class="flex"><a class="btn btn-sm" href="#start">Create a project</a></div> </article> </div></section><template> <section class="flex flex-col gap-xl p-xl bg-surface-base fg-text-body text-sm" aria-labelledby="bento-title"> <header class="flex flex-col gap-xs max-w(560)"> <p class="eyebrow">Platform</p> <h2 class="heading heading-xl" id="bento-title">Everything a deploy needs</h2> </header> <div class="bento"> <article class="card card-split bento-large"> <img class="card-media" src="/demo/moonstone.svg" alt> <header class="card-header"> <h3 class="card-title">Live at the edge</h3> <p class="card-description"> Every push is served from 14 regions before the review is done. </p> </header> <p class="card-body"> Static files, functions and images are cached where the reader is, and purged the moment a deploy replaces them. </p> <footer class="card-footer"> <a class="btn btn-sm" href="#regions">See the regions</a> </footer> </article> <article class="card bento-tall"> <header class="card-header"> <h3 class="card-title">Reviewed together</h3> <p class="card-description">Comments land on the preview, beside what they are about.</p> </header> <div class="card-body flex flex-col gap-sm"> <div class="avatar-group" role="group" aria-label="Ada Lovelace, Alan Turing, Grace Hopper and 5 others"> <span class="avatar avatar-sm"> <img class="avatar-image" src="/demo/portrait-1.svg" alt> </span> <span class="avatar avatar-sm"> <img class="avatar-image" src="/demo/portrait-2.svg" alt> </span> <span class="avatar avatar-sm"> <img class="avatar-image" src="/demo/portrait-3.svg" alt> </span> <span class="avatar avatar-sm" aria-hidden="true">+5</span> </div> <p class="m(0)"> Eight people left 23 comments on this week's previews. Four are still open. </p> </div> <footer class="card-footer"> <a class="btn btn-sm" href="#comments">Open comments</a> </footer> </article> <article class="card"> <div class="stat"> <p class="stat-label">Cold builds</p> <div class="stat-row"> <p class="stat-value">38s</p> <p class="stat-delta">21% faster</p> </div> <p class="stat-description">Caches are restored before the install.</p> </div> </article> <article class="card"> <header class="card-header"> <h3 class="card-title">Rollbacks</h3> <p class="card-description">Any deploy is one click away, and so is the one before it.</p> </header> </article> <article class="card bento-wide"> <header class="card-header"> <h3 class="card-title">Builds this week</h3> <p class="card-description">Thursday so far</p> </header> <figure class="chart chart-quiet" style="--chart-height: 4.5rem"> <div class="chart-body"> <svg class="chart-plot" role="list" aria-label="Builds per day, this week"> <g aria-hidden="true"> <line class="chart-grid chart-grid-base" x1="0" y1="100%" x2="100%" y2="100%" /> <line class="chart-grid" x1="0" y1="75%" x2="100%" y2="75%" /> <line class="chart-grid" x1="0" y1="50%" x2="100%" y2="50%" /> <line class="chart-grid" x1="0" y1="25%" x2="100%" y2="25%" /> <line class="chart-grid" x1="0" y1="0%" x2="100%" y2="0%" /> <text class="chart-tick chart-tick-x" x="7.143%" y="100%">Mon</text> <text class="chart-tick chart-tick-x" x="21.429%" y="100%">Tue</text> <text class="chart-tick chart-tick-x" x="35.714%" y="100%">Wed</text> <text class="chart-tick chart-tick-x" x="50%" y="100%">Thu</text> <text class="chart-tick chart-tick-x" x="64.286%" y="100%">Fri</text> <text class="chart-tick chart-tick-x" x="78.571%" y="100%">Sat</text> <text class="chart-tick chart-tick-x" x="92.857%" y="100%">Sun</text> </g> <g class="chart-point" role="listitem" aria-label="Mon: 42"> <rect class="chart-hit" x="0%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="2.714%" y="47.5%" width="8.857%" height="52.5%" /> </g> <g class="chart-point" role="listitem" aria-label="Tue: 58"> <rect class="chart-hit" x="14.286%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="17%" y="27.5%" width="8.857%" height="72.5%" /> </g> <g class="chart-point" role="listitem" aria-label="Wed: 36"> <rect class="chart-hit" x="28.571%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="31.286%" y="55%" width="8.857%" height="45%" /> </g> <g class="chart-point" role="listitem" aria-label="Thu: 71" aria-current="true"> <rect class="chart-hit" x="42.857%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="45.571%" y="11.25%" width="8.857%" height="88.75%" /> </g> <g class="chart-point" role="listitem" aria-label="Fri: 0"> <rect class="chart-hit" x="57.143%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="59.857%" y="99.4%" width="8.857%" height="0.6%" /> </g> <g class="chart-point" role="listitem" aria-label="Sat: 0"> <rect class="chart-hit" x="71.429%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="74.143%" y="99.4%" width="8.857%" height="0.6%" /> </g> <g class="chart-point" role="listitem" aria-label="Sun: 0"> <rect class="chart-hit" x="85.714%" y="0" width="14.286%" height="100%" /> <rect class="chart-bar" x="88.429%" y="99.4%" width="8.857%" height="0.6%" /> </g> </svg> </div> </figure> </article> <article class="sheet sheet-inverse bento-wide flex flex-col justify-between gap-md p(20)"> <div class="flex flex-col gap-3xs"> <h3 class="heading heading-sm fg-text-inverse">Start on the free plan</h3> <p class="m(0)">Three projects and every feature above. No card needed.</p> </div> <div class="flex"><a class="btn btn-sm" href="#start">Create a project</a></div> </article> </div> </section></template>#版面配置原理
- 依自身寬度計算欄數。 容器無法查詢自身尺寸,因此 Bento 採用與自動網格相同的做法,用
repeat(auto-fill, …)搭配最小欄軌寬度。寬度達 48rem 時,最小欄軌寬度是總寬的四分之一。達 28rem 時是二分之一,再窄就占滿。因此只會自動排成四欄、兩欄或一欄,不會出現三欄。 - 跨格範圍隨欄數調整。 Bento 版面是名為
bento的尺寸查詢容器,以同一個寬度作為查詢依據。bento-wide、bento-tall和bento-large要等 Bento 寬度達 28rem、有兩欄可用時,才會跨越多格。bento-full在任何寬度都占滿整列。 - 每列都有最小高度。 每列至少有
--bento-row指定的高度,預設為 10rem,並會隨內容增高。無論內容多寡,高區塊都占兩列,加上兩列之間的間距。 - 區塊依標記順序排列。 上方六個區塊依下列順序寫入標記,在四欄和兩欄版面都能緊密排列。先放大區塊和高區塊,接著用兩個小區塊填滿高區塊旁的一欄,最後放兩個寬區塊。
- 用元件呈現各區塊。 分欄卡片在區塊夠寬時將圖片放在文字旁,較窄時則放在文字上方。數據分別用統計數值和低調圖表呈現,最後一個區塊使用本頁唯一的反色面板。
#區塊
未加類別的區塊占一格。以下四個類別可放大區塊:
| 類別 | 四欄版面 | 兩欄版面 | 單欄版面 |
|---|---|---|---|
bento-wide | 兩欄 | 整列 | 一格 |
bento-tall | 兩列 | 兩列 | 一格 |
bento-large | 兩欄、兩列 | 整列寬、兩列高 | 一格 |
bento-full | 整列 | 整列 | 整列 |
區塊
<div class="bento p-lg bg-surface-base fg-text-muted text-2xl font-mono" style="--bento-row: 5rem"> <div class="well flex items-center justify-center bento-large">bento-large</div> <div class="well flex items-center justify-center bento-tall">bento-tall</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center bento-wide">bento-wide</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center bento-full">bento-full</div></div><div className="bento p-lg bg-surface-base fg-text-muted text-2xl font-mono" style={{ '--bento-row': '5rem' } as React.CSSProperties}> <div className="well flex items-center justify-center bento-large">bento-large</div> <div className="well flex items-center justify-center bento-tall">bento-tall</div> <div className="well flex items-center justify-center">One cell</div> <div className="well flex items-center justify-center">One cell</div> <div className="well flex items-center justify-center bento-wide">bento-wide</div> <div className="well flex items-center justify-center">One cell</div> <div className="well flex items-center justify-center">One cell</div> <div className="well flex items-center justify-center bento-full">bento-full</div></div><div class="bento p-lg bg-surface-base fg-text-muted text-2xl font-mono" style="--bento-row: 5rem"> <div class="well flex items-center justify-center bento-large">bento-large</div> <div class="well flex items-center justify-center bento-tall">bento-tall</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center bento-wide">bento-wide</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center bento-full">bento-full</div></div><template> <div class="bento p-lg bg-surface-base fg-text-muted text-2xl font-mono" style="--bento-row: 5rem"> <div class="well flex items-center justify-center bento-large">bento-large</div> <div class="well flex items-center justify-center bento-tall">bento-tall</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center bento-wide">bento-wide</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center">One cell</div> <div class="well flex items-center justify-center bento-full">bento-full</div> </div></template>只讓少數區塊跨格。如果每個區塊都放大,效果就像把自動網格的區塊全部放大。如果沒有任何區塊放大,讀者就看不出該先看哪一個。
#順序
區塊依標記順序排列,每個區塊都放在前一個區塊之後第一個放得下的位置。如果列尾放不下寬區塊,它就會移到下一列,並在前一列留下空格。網格會保留這個空格,讓畫面上的排列順序與鍵盤導覽及螢幕閱讀器遵循的標記順序一致。
請安排區塊的標記順序,讓它們能緊密排列。如果順序不影響理解,例如一面標誌牆或一組圖片,可用 bento-dense 讓後面的區塊往前補空格。
順序
<div class="flex flex-col gap-md w-full fg-text-muted text-sm"> <p class="eyebrow">bento</p> <div class="bento" style="--bento-row: 3rem"> <div class="well flex items-center justify-center">1</div> <div class="well flex items-center justify-center bento-wide">2</div> <div class="well flex items-center justify-center bento-wide">3</div> <div class="well flex items-center justify-center">4</div> <div class="well flex items-center justify-center">5</div> </div> <p class="eyebrow">bento bento-dense</p> <div class="bento bento-dense" style="--bento-row: 3rem"> <div class="well flex items-center justify-center">1</div> <div class="well flex items-center justify-center bento-wide">2</div> <div class="well flex items-center justify-center bento-wide">3</div> <div class="well flex items-center justify-center">4</div> <div class="well flex items-center justify-center">5</div> </div></div><div className="flex flex-col gap-md w-full fg-text-muted text-sm"> <p className="eyebrow">bento</p> <div className="bento" style={{ '--bento-row': '3rem' } as React.CSSProperties}> <div className="well flex items-center justify-center">1</div> <div className="well flex items-center justify-center bento-wide">2</div> <div className="well flex items-center justify-center bento-wide">3</div> <div className="well flex items-center justify-center">4</div> <div className="well flex items-center justify-center">5</div> </div> <p className="eyebrow">bento bento-dense</p> <div className="bento bento-dense" style={{ '--bento-row': '3rem' } as React.CSSProperties}> <div className="well flex items-center justify-center">1</div> <div className="well flex items-center justify-center bento-wide">2</div> <div className="well flex items-center justify-center bento-wide">3</div> <div className="well flex items-center justify-center">4</div> <div className="well flex items-center justify-center">5</div> </div></div><div class="flex flex-col gap-md w-full fg-text-muted text-sm"> <p class="eyebrow">bento</p> <div class="bento" style="--bento-row: 3rem"> <div class="well flex items-center justify-center">1</div> <div class="well flex items-center justify-center bento-wide">2</div> <div class="well flex items-center justify-center bento-wide">3</div> <div class="well flex items-center justify-center">4</div> <div class="well flex items-center justify-center">5</div> </div> <p class="eyebrow">bento bento-dense</p> <div class="bento bento-dense" style="--bento-row: 3rem"> <div class="well flex items-center justify-center">1</div> <div class="well flex items-center justify-center bento-wide">2</div> <div class="well flex items-center justify-center bento-wide">3</div> <div class="well flex items-center justify-center">4</div> <div class="well flex items-center justify-center">5</div> </div></div><template> <div class="flex flex-col gap-md w-full fg-text-muted text-sm"> <p class="eyebrow">bento</p> <div class="bento" style="--bento-row: 3rem"> <div class="well flex items-center justify-center">1</div> <div class="well flex items-center justify-center bento-wide">2</div> <div class="well flex items-center justify-center bento-wide">3</div> <div class="well flex items-center justify-center">4</div> <div class="well flex items-center justify-center">5</div> </div> <p class="eyebrow">bento bento-dense</p> <div class="bento bento-dense" style="--bento-row: 3rem"> <div class="well flex items-center justify-center">1</div> <div class="well flex items-center justify-center bento-wide">2</div> <div class="well flex items-center justify-center bento-wide">3</div> <div class="well flex items-center justify-center">4</div> <div class="well flex items-center justify-center">5</div> </div> </div></template>第一個 Bento 的寬區塊在第一個區塊後方留下空格。第二個 Bento 的第四個區塊移到那個空格,畫面上排在第二,閱讀順序仍是第四。
#列高
--bento-row 設定列高下限,預設為 10rem。區塊的文字較多時,該列會增高,同列其他區塊也會一起拉高,避免截斷內容。如果區塊只放一個數值或一行文字,可以降低列高,例如本頁的示意圖使用 5rem。放圖片時則可提高列高。
--bento-gap 設定區塊間距,預設為 1rem。欄數計算需要用到這個值,因此間距須透過這個自訂屬性設定,不能用間距工具類別代替。
#使用時機
| 區塊特性 | 版面配置 |
|---|---|
| 有不同尺寸,部分區塊需要強調 | Bento |
| 尺寸一致,數量不限 | 自動網格 |
| 各區塊高度隨內容而定,例如相片集 | 瀑布流 |
| 設計指定欄數 | grid grid-cols(3) 和 grid-col-span(2),搭配容器變體 |
Bento 版面適合一次編排好六到十個區塊的內容。專案清單或搜尋結果等會持續增加的集合,各項目的重要性相近,適合使用自動網格。
#無障礙
- 閱讀與鍵盤導覽都依標記順序進行。請把最重要的區塊放在最前面,並將
bento-dense留給順序不影響理解的項目集合。 - 螢幕閱讀器無法透過尺寸傳達重點。請將讀者最需要的標題放在大區塊,並讓各區塊的標題說明其主題,讓讀者瀏覽標題清單就能掌握整組內容。
- 如果整個區塊只有一個連結,請將
card-interactive直接加在連結元素上,讓該連結本身就是卡片。請勿另加一個連結覆蓋整張卡片。
#類別
| 類別 | 說明 |
|---|---|
bento | 格線依自身寬度調整欄數,達 48rem 時為四欄,達 28rem 時為兩欄,低於 28rem 時為一欄。每列至少有 --bento-row 高。這是名為 bento 的尺寸查詢容器,本身不繪製任何內容 |
bento-dense | 後面的圖塊會往上填補前面跨欄或跨列的圖塊留下的空位。畫面順序會與閱讀順序不同,因此只適用於順序無關緊要的圖塊集合。搭配 bento 使用 |
bento-wide | bento 寬度達 28rem 時,圖塊跨兩欄。在兩欄版面中會占滿整列 |
bento-tall | bento 寬度達 28rem 時,圖塊跨兩列 |
bento-large | bento 寬度達 28rem 時,圖塊跨兩欄、兩列 |
bento-full | 圖塊在任何寬度下都占滿整列 |
#自訂屬性
| 屬性 | 預設值 | 說明 |
|---|---|---|
--bento-row | 10rem | 列的最小高度。列會隨其中最高的內容增高 |
--bento-gap | 1rem | 圖塊間距,計算欄數時會一併納入 |
#相關內容
- 自動網格在可用空間內排入最多等寬欄,由網格自行計算欄數。
- 瀑布流高低不一的區塊緊密排入各欄,底下不留多餘空隙。
- 卡片帶有浮起效果的面板,各部分會依卡片可用空間調整。
- 統計數值呈現單一數值、它衡量的項目及其變動:低調的標籤、大字的數值和變化幅度。
- 圖表用單一 SVG 呈現數值,適應任何寬度,支援從折線圖到旭日圖等二十多種圖表。
- 表面托盤、面板與凹槽構成所有元件共用的材質層次。