網站導覽
前後頁導覽
在文章底部提供上一篇和下一篇的連結。
本頁內容
前後頁導覽放在文章底部,以兩個並排的連結指向上一篇和下一篇。每個連結都是平坦的面板,在目的頁面的標題上方放一個低調的方向標籤。連結以 rel="prev" 和 rel="next" 表示各自的方向,樣式表會讀取這些屬性,因此不必另加指定方向的類別。
前後頁導覽
<nav class="pager max-w(560) mx-auto" aria-label="Guide pages"> <a class="pager-link" rel="prev" href="#installation"> <span class="pager-label"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M13.6362 7.5189A0.4947 0.4947 0 0 0 13.5 7.5L2.4755 7.5006A0.5 0.5 0 0 0 2.4266 8.4946L2.5 8.5H13.5A0.4947 0.4947 0 0 0 13.6362 8.4811A0.7009 0.7009 0 0 0 13.6362 7.5189Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(180 8 8)" /><path d="M8 4.5L13.2348 7.8313A0.2 0.2 0 0 1 13.2348 8.1687L8 11.5" transform="rotate(180 8 8)" /> </svg>Previous </span> <span class="pager-title">Installation</span> </a> <a class="pager-link" rel="next" href="#theming"> <span class="pager-label"> Next<svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M13.6362 7.5189A0.4947 0.4947 0 0 0 13.5 7.5L2.4755 7.5006A0.5 0.5 0 0 0 2.4266 8.4946L2.5 8.5H13.5A0.4947 0.4947 0 0 0 13.6362 8.4811A0.7009 0.7009 0 0 0 13.6362 7.5189Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M8 4.5L13.2348 7.8313A0.2 0.2 0 0 1 13.2348 8.1687L8 11.5" /> </svg> </span> <span class="pager-title">Theming</span> </a></nav>import ArrowLeftIcon from '@master/icons-react/native/16/soft/arrow-left'import ArrowRightIcon from '@master/icons-react/native/16/soft/arrow-right'<nav className="pager max-w(560) mx-auto" aria-label="Guide pages"> <a className="pager-link" rel="prev" href="#installation"> <span className="pager-label"><ArrowLeftIcon className="icon" />Previous</span> <span className="pager-title">Installation</span> </a> <a className="pager-link" rel="next" href="#theming"> <span className="pager-label">Next<ArrowRightIcon className="icon" /></span> <span className="pager-title">Theming</span> </a></nav><script> import ArrowLeftIcon from '@master/icons-svelte/native/16/soft/arrow-left' import ArrowRightIcon from '@master/icons-svelte/native/16/soft/arrow-right'</script><nav class="pager max-w(560) mx-auto" aria-label="Guide pages"> <a class="pager-link" rel="prev" href="#installation"> <span class="pager-label"><ArrowLeftIcon class="icon" />Previous</span> <span class="pager-title">Installation</span> </a> <a class="pager-link" rel="next" href="#theming"> <span class="pager-label">Next<ArrowRightIcon class="icon" /></span> <span class="pager-title">Theming</span> </a></nav><script setup>import ArrowLeftIcon from '@master/icons-vue/native/16/soft/arrow-left'import ArrowRightIcon from '@master/icons-vue/native/16/soft/arrow-right'</script><template> <nav class="pager max-w(560) mx-auto" aria-label="Guide pages"> <a class="pager-link" rel="prev" href="#installation"> <span class="pager-label"><ArrowLeftIcon class="icon" />Previous</span> <span class="pager-title">Installation</span> </a> <a class="pager-link" rel="next" href="#theming"> <span class="pager-label">Next<ArrowRightIcon class="icon" /></span> <span class="pager-title">Theming</span> </a> </nav></template>#由屬性決定連結位置
rel 是用來描述連結與所在頁面關係的 HTML 屬性,prev 和 next 是其中兩個值。前後頁導覽的連結會帶有其中一個值,以符合有順序的頁面所需的標記語意。樣式表會依這個值調整以下三項:
- 下一頁連結放在整列末端,文字也向末端對齊。
- 指標移入時,箭頭會朝所指方向移動:下一頁向前,上一頁向後。在由右至左書寫的頁面中,兩支箭頭都會反向。
- 只有下一頁時,連結仍會靠在整列末端,符合讀者視線和觸控操作的習慣。
箭頭是標籤裡的圖示,使用 16px 的 Master Icons 圖稿,由標籤以 14px 呈現:上一頁在文字前放 arrow-left,下一頁在文字後放 arrow-right。
省略沒有對應頁面的連結。指南的第一頁只放下一頁,最後一頁只放上一頁。
第一頁
<nav class="pager max-w(560) mx-auto" aria-label="Guide pages"> <a class="pager-link" rel="next" href="#installation"> <span class="pager-label"> Next<svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M13.6362 7.5189A0.4947 0.4947 0 0 0 13.5 7.5L2.4755 7.5006A0.5 0.5 0 0 0 2.4266 8.4946L2.5 8.5H13.5A0.4947 0.4947 0 0 0 13.6362 8.4811A0.7009 0.7009 0 0 0 13.6362 7.5189Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M8 4.5L13.2348 7.8313A0.2 0.2 0 0 1 13.2348 8.1687L8 11.5" /> </svg> </span> <span class="pager-title">Installation</span> </a></nav>import ArrowRightIcon from '@master/icons-react/native/16/soft/arrow-right'<nav className="pager max-w(560) mx-auto" aria-label="Guide pages"> <a className="pager-link" rel="next" href="#installation"> <span className="pager-label">Next<ArrowRightIcon className="icon" /></span> <span className="pager-title">Installation</span> </a></nav><script> import ArrowRightIcon from '@master/icons-svelte/native/16/soft/arrow-right'</script><nav class="pager max-w(560) mx-auto" aria-label="Guide pages"> <a class="pager-link" rel="next" href="#installation"> <span class="pager-label">Next<ArrowRightIcon class="icon" /></span> <span class="pager-title">Installation</span> </a></nav><script setup>import ArrowRightIcon from '@master/icons-vue/native/16/soft/arrow-right'</script><template> <nav class="pager max-w(560) mx-auto" aria-label="Guide pages"> <a class="pager-link" rel="next" href="#installation"> <span class="pager-label">Next<ArrowRightIcon class="icon" /></span> <span class="pager-title">Installation</span> </a> </nav></template>#外觀與動態效果
連結是帶有一道輪廓線的平坦面板,採用大型控制項的圓角。指標移入時,面板會抬高一階,箭頭朝所指方向移動 2px。按下時,面板會凹下。啟用減少動態效果時,箭頭會留在原位。
前後頁導覽本身是尺寸查詢容器。當它的寬度小於 26rem,兩個連結會改為上下排列,各自撐滿導覽寬度,上一頁排在最前面。
#前後頁導覽或分頁導覽
前後頁導覽用於依序閱讀的頁面,並會顯示各頁標題。分頁導覽用於切換同一份長清單中有頁碼的各頁。要呈現頁面在網站中的位置,請用麵包屑導覽。
#無障礙
- 將連結放在設有
aria-label的<nav>裡,讓使用者能從頁面上的其他導覽區域中辨認出這個地標。 - 連結名稱由標籤和標題組成,例如「下一頁,主題設定」。請保留方向標籤,讓讀者知道連結指向哪個方向。
- 箭頭是帶有
aria-hidden="true"的圖示,螢幕閱讀器不會讀出。
#類別
| 類別 | 說明 |
|---|---|
pager | 兩個連結並排放在具有無障礙名稱的 nav 中。容器寬度小於 26rem 時,改為上下排列 |
pager-link | 單一連結,帶有 rel="prev" 或 rel="next"。預設採平面樣式,指標移入時呈現一階的浮起效果。下一頁連結位於末端,文字也向末端對齊。 |
pager-label | 標題上方以較不醒目的文字顯示「上一頁」或「下一頁」,並搭配指向對應方向的圖示:上一頁的箭頭放在文字前,下一頁的箭頭放在文字後。標籤會將圖示設為 14px,並在由右至左書寫的頁面中將它反向 |
pager-title | 連結所指向的頁面標題 |