网站页眉包含品牌标识、主要链接和最希望访客执行的操作。这个区块在导航栏的基础上加入了实际网站所需的内容:一个导航项下方的菜单、空间不足时隐藏的次要操作,以及在手机上接管导航的抽屉。所有这些都无需脚本。
页眉
<a class="skip" href="#header-main">Skip to content</a><header class="navbar" style="--navbar-padding-x: 1.5rem"> <a class="navbar-brand" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /><path d="M8 4.3333A3.6667 3.6667 0 0 1 8 11.6667Z" fill="currentColor" stroke="none" /> </svg>Atlas </a> <nav class="navbar-nav" aria-label="Main"> <button type="button" class="navbar-link" popovertarget="header-product"> Product<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="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" transform="rotate(90 8 8)" /> </svg> </button> <div class="popover p(4)" id="header-product" popover> <ul class="list list-interactive w(320)"> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M10 1.6667C5 5.8333 4.5833 10.8333 7.0833 15.4167H12.9167C15.4167 10.8333 15 5.8333 10 1.6667Z" /><circle cx="10" cy="8.3333" r="1" fill="currentColor" stroke="none" /><path d="M12.5059 15.4167Q12.6134 15.5471 12.7721 15.6266L15.7283 17.1047A0.8249 0.8249 0 0 0 16.9109 16.5023L17.6842 11.8631A0.8257 0.8257 0 0 0 17.4914 11.1839L14.9083 8.2317A0.8274 0.8274 0 0 0 14.1839 7.9561C14.3744 8.793 14.4431 9.6377 14.3995 10.4832L14.5438 9.7135L16.4181 11.8557L15.7727 15.7292L13.6179 14.6519L13.9005 13.1446C13.6551 13.9094 13.3247 14.6686 12.9167 15.4167H12.5059ZM5.8161 7.9561A0.8199 0.8199 0 0 0 5.0917 8.2318L2.5086 11.1839A0.8257 0.8257 0 0 0 2.3158 11.8631L3.089 16.5023A0.825 0.825 0 0 0 4.2717 17.1047L7.2279 15.6266Q7.3866 15.5471 7.4941 15.4167H7.0833C6.6753 14.6686 6.3449 13.9094 6.0995 13.1446L6.3821 14.6519L4.2274 15.7292L3.5818 11.8557L5.4562 9.7135L5.6005 10.4832C5.5569 9.6377 5.6256 8.793 5.8161 7.9561Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M8.3333 18.75L11.6667 18.75" /> </svg> </span> <div class="list-body"> <p class="list-title">Deployments</p> <p class="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="10" cy="10" r="7.5" /><path d="M10.9634 2.5621A7.504 7.504 0 0 0 9.0366 2.5621Q7.6452 3.9922 6.8517 5.7596Q6.0678 7.5056 5.9561 9.375H2.5261A7.4963 7.4963 0 0 0 2.5261 10.625H5.9561Q6.0678 12.4944 6.8517 14.2404Q7.6452 16.0078 9.0366 17.4378A7.492 7.492 0 0 0 10.9634 17.4378Q12.3547 16.0078 13.1483 14.2404Q13.9322 12.4944 14.0439 10.625H17.4739A7.4963 7.4963 0 0 0 17.4739 9.375H14.0439Q13.9322 7.5056 13.1483 5.7596Q12.3547 3.9922 10.9634 2.5621ZM12.0079 6.2716Q12.6818 7.7726 12.7913 9.375H7.2087Q7.3182 7.7726 7.9921 6.2716Q8.7137 4.6643 10 3.3652Q11.2863 4.6643 12.0079 6.2716ZM7.9921 13.7284Q7.3182 12.2274 7.2087 10.625H12.7913Q12.6818 12.2274 12.0079 13.7284Q11.2863 15.3357 10 16.6348Q8.7137 15.3357 7.9921 13.7284Z" fill="currentColor" stroke="none" fill-rule="evenodd" /> </svg> </span> <div class="list-body"> <p class="list-title">Domains</p> <p class="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <rect x="3" y="10" width="3" height="7.5" rx="0.75" /><rect x="8.5" y="4" width="3" height="13.5" rx="0.75" /><rect x="14" y="7.5" width="3" height="10" rx="0.75" /> </svg> </span> <div class="list-body"> <p class="list-title">Analytics</p> <p class="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M9.6667 2.6667Q10 2.5 10.3333 2.6667C12.0833 4 14.5833 4.75 16.3333 5Q16.6667 5 16.6667 5.3333V9.1667C16.6667 13.3333 14.1667 16.25 10.3333 17.4Q10 17.5 9.6667 17.4C5.8333 16.25 3.3333 13.3333 3.3333 9.1667V5.3333Q3.3333 5 3.6667 5C5.4167 4.75 7.9167 4 9.6667 2.6667Z" /> </svg> </span> <div class="list-body"> <p class="list-title">Firewall</p> <p class="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a class="navbar-link" href="#">Pricing</a> <a class="navbar-link" href="#">Docs</a> <a class="navbar-link" href="#">Changelog</a> </nav> <div class="navbar-end"> <a class="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a class="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" commandfor="header-menu" command="show-modal" aria-label="Open the menu"> <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="M3 5.5L13 5.5" /><path d="M3 10.5L13 10.5" /> </svg> </button> </div> <dialog class="dialog dialog-drawer" id="header-menu" closedby="any" aria-label="Menu" style="--dialog-width: 20rem"> <div class="dialog-body flex flex-col gap-md"> <nav class="nav" aria-label="Main, in the menu"> <div class="nav-label">Product</div> <a class="nav-item" href="#"> <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="M8 1.3333C4 4.6667 3.6667 8.6667 5.6667 12.3333H10.3333C12.3333 8.6667 12 4.6667 8 1.3333Z" /><circle cx="8" cy="6.6667" r="0.85" fill="currentColor" stroke="none" /><path d="M10.016 12.3333Q10.1079 12.4463 10.2446 12.5147L12.5342 13.6594A0.6999 0.6999 0 0 0 13.5377 13.1484L14.1443 9.5091Q14.1989 9.1824 13.9807 8.9328L11.9808 6.6473A0.7011 0.7011 0 0 0 11.3582 6.4146C11.5022 7.0678 11.5536 7.7269 11.5195 8.3865L11.635 7.7707L13.1346 9.4845L12.6181 12.5833L10.8942 11.7215L11.1203 10.5157C10.924 11.1275 10.6597 11.7349 10.3333 12.3333H10.016ZM4.6418 6.4146A0.6958 0.6958 0 0 0 4.0192 6.6473L2.0193 8.9328Q1.8012 9.1824 1.8557 9.5091L2.4623 13.1484A0.6999 0.6999 0 0 0 3.4658 13.6594L5.7554 12.5147Q5.8921 12.4463 5.984 12.3333H5.6667C5.3403 11.7349 5.076 11.1275 4.8797 10.5157L5.1058 11.7215L3.3819 12.5833L2.8654 9.4845L4.365 7.7707L4.4805 8.3865C4.4464 7.7269 4.4978 7.0678 4.6418 6.4146Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M6.6667 15L9.3333 15" /> </svg>Deployments </a> <a class="nav-item" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /><path d="M8.7707 2.0497A6.0005 6.0005 0 0 0 7.2293 2.0497Q6.1162 3.1938 5.4813 4.6077Q4.8542 6.0044 4.7648 7.5H2.0209A5.9913 5.9913 0 0 0 2.0209 8.5H4.7648Q4.8542 9.9956 5.4813 11.3923Q6.1162 12.8062 7.2293 13.9503A6.0005 6.0005 0 0 0 8.7707 13.9503Q9.8838 12.8062 10.5187 11.3923Q11.1458 9.9956 11.2352 8.5H13.9791A5.9913 5.9913 0 0 0 13.9791 7.5H11.2352Q11.1458 6.0044 10.5187 4.6077Q9.8838 3.1938 8.7707 2.0497ZM9.6064 5.0173Q10.1455 6.2181 10.2331 7.5H5.7669Q5.8545 6.2181 6.3936 5.0173Q6.971 3.7314 8 2.6921Q9.029 3.7314 9.6064 5.0173ZM6.3936 10.9827Q5.8545 9.7819 5.7669 8.5H10.2331Q10.1455 9.7819 9.6064 10.9827Q9.029 12.2686 8 13.3079Q6.971 12.2686 6.3936 10.9827Z" fill="currentColor" stroke="none" fill-rule="evenodd" /> </svg>Domains </a> <a class="nav-item" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <rect x="2" y="8" width="2.5" height="6" rx="0.75" /><rect x="6.75" y="3" width="2.5" height="11" rx="0.75" /><rect x="11.5" y="6" width="2.5" height="8" rx="0.75" /> </svg>Analytics </a> <a class="nav-item" href="#"> <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="M7.7333 2.1333Q8 2 8.2667 2.1333C9.6667 3.2 11.6667 3.8 13.0667 4Q13.3333 4 13.3333 4.2667V7.3333C13.3333 10.6667 11.3333 13 8.2667 13.92Q8 14 7.7333 13.92C4.6667 13 2.6667 10.6667 2.6667 7.3333V4.2667Q2.6667 4 2.9333 4C4.3333 3.8 6.3333 3.2 7.7333 2.1333Z" /> </svg>Firewall </a> <div class="nav-label">Resources</div> <a class="nav-item" href="#">Pricing</a> <a class="nav-item" href="#">Docs</a> <a class="nav-item" href="#">Changelog</a> </nav> </div> <footer class="dialog-footer"> <a class="btn" href="#">Sign in</a> <a class="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="header-menu" command="close" aria-label="Close the menu"> <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="M4 4L12 12" /><path d="M4 12L12 4" /> </svg> </button> </dialog></header><main class="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main" tabindex="-1"> <h1 class="heading heading-2xl">The page under the header</h1> <p class="lead"> Scroll, and the bar takes its material. Open Product for the menu; choose Phone for the drawer. </p> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div></main>import ContrastIcon from '@master/icons-react/native/16/soft/contrast'import ChevronDownIcon from '@master/icons-react/native/16/soft/chevron-down'import RocketIcon20 from '@master/icons-react/native/20/soft/rocket'import GlobeIcon20 from '@master/icons-react/native/20/soft/globe'import ChartBarIcon20 from '@master/icons-react/native/20/soft/chart-bar'import ShieldIcon20 from '@master/icons-react/native/20/soft/shield'import MenuIcon from '@master/icons-react/native/16/soft/menu'import RocketIcon16 from '@master/icons-react/native/16/soft/rocket'import GlobeIcon16 from '@master/icons-react/native/16/soft/globe'import ChartBarIcon16 from '@master/icons-react/native/16/soft/chart-bar'import ShieldIcon16 from '@master/icons-react/native/16/soft/shield'import XIcon from '@master/icons-react/native/16/soft/x'<> <a className="skip" href="#header-main">Skip to content</a> <header className="navbar" style={{ '--navbar-padding-x': '1.5rem' } as React.CSSProperties}> <a className="navbar-brand" href="#"><ContrastIcon className="icon" />Atlas</a> <nav className="navbar-nav" aria-label="Main"> <button type="button" className="navbar-link" popoverTarget="header-product"> Product<ChevronDownIcon className="icon" /> </button> <div className="popover p(4)" id="header-product" popover=""> <ul className="list list-interactive w(320)"> <li> <a className="list-row" href="#"> <span className="list-media"><RocketIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Deployments</p> <p className="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a className="list-row" href="#"> <span className="list-media"><GlobeIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Domains</p> <p className="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a className="list-row" href="#"> <span className="list-media"><ChartBarIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Analytics</p> <p className="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a className="list-row" href="#"> <span className="list-media"><ShieldIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Firewall</p> <p className="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a className="navbar-link" href="#">Pricing</a> <a className="navbar-link" href="#">Docs</a> <a className="navbar-link" href="#">Changelog</a> </nav> <div className="navbar-end"> <a className="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a className="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" className="btn btn-quiet btn-square btn-sm navbar-toggle" {...{ commandfor: 'header-menu', command: 'show-modal' }} aria-label="Open the menu"> <MenuIcon className="icon" /> </button> </div> <dialog className="dialog dialog-drawer" id="header-menu" closedby="any" aria-label="Menu" style={{ '--dialog-width': '20rem' } as React.CSSProperties}> <div className="dialog-body flex flex-col gap-md"> <nav className="nav" aria-label="Main, in the menu"> <div className="nav-label">Product</div> <a className="nav-item" href="#"><RocketIcon16 className="icon" />Deployments</a> <a className="nav-item" href="#"><GlobeIcon16 className="icon" />Domains</a> <a className="nav-item" href="#"><ChartBarIcon16 className="icon" />Analytics</a> <a className="nav-item" href="#"><ShieldIcon16 className="icon" />Firewall</a> <div className="nav-label">Resources</div> <a className="nav-item" href="#">Pricing</a> <a className="nav-item" href="#">Docs</a> <a className="nav-item" href="#">Changelog</a> </nav> </div> <footer className="dialog-footer"> <a className="btn" href="#">Sign in</a> <a className="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" className="btn btn-quiet btn-square btn-sm dialog-close" {...{ commandfor: 'header-menu', command: 'close' }} aria-label="Close the menu"> <XIcon className="icon" /> </button> </dialog> </header> <main className="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main" tabIndex={-1}> <h1 className="heading heading-2xl">The page under the header</h1> <p className="lead"> Scroll, and the bar takes its material. Open Product for the menu; choose Phone for the drawer. </p> <div className="sheet p-xl h(240)"></div> <div className="sheet p-xl h(240)"></div> <div className="sheet p-xl h(240)"></div> </main></><script> import ContrastIcon from '@master/icons-svelte/native/16/soft/contrast' import ChevronDownIcon from '@master/icons-svelte/native/16/soft/chevron-down' import RocketIcon20 from '@master/icons-svelte/native/20/soft/rocket' import GlobeIcon20 from '@master/icons-svelte/native/20/soft/globe' import ChartBarIcon20 from '@master/icons-svelte/native/20/soft/chart-bar' import ShieldIcon20 from '@master/icons-svelte/native/20/soft/shield' import MenuIcon from '@master/icons-svelte/native/16/soft/menu' import RocketIcon16 from '@master/icons-svelte/native/16/soft/rocket' import GlobeIcon16 from '@master/icons-svelte/native/16/soft/globe' import ChartBarIcon16 from '@master/icons-svelte/native/16/soft/chart-bar' import ShieldIcon16 from '@master/icons-svelte/native/16/soft/shield' import XIcon from '@master/icons-svelte/native/16/soft/x'</script><a class="skip" href="#header-main">Skip to content</a><header class="navbar" style="--navbar-padding-x: 1.5rem"> <a class="navbar-brand" href="#"><ContrastIcon class="icon" />Atlas</a> <nav class="navbar-nav" aria-label="Main"> <button type="button" class="navbar-link" popovertarget="header-product"> Product<ChevronDownIcon class="icon" /> </button> <div class="popover p(4)" id="header-product" popover> <ul class="list list-interactive w(320)"> <li> <a class="list-row" href="#"> <span class="list-media"><RocketIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Deployments</p> <p class="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><GlobeIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Domains</p> <p class="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ChartBarIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Analytics</p> <p class="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ShieldIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Firewall</p> <p class="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a class="navbar-link" href="#">Pricing</a> <a class="navbar-link" href="#">Docs</a> <a class="navbar-link" href="#">Changelog</a> </nav> <div class="navbar-end"> <a class="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a class="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" commandfor="header-menu" command="show-modal" aria-label="Open the menu"> <MenuIcon class="icon" /> </button> </div> <dialog class="dialog dialog-drawer" id="header-menu" closedby="any" aria-label="Menu" style="--dialog-width: 20rem"> <div class="dialog-body flex flex-col gap-md"> <nav class="nav" aria-label="Main, in the menu"> <div class="nav-label">Product</div> <a class="nav-item" href="#"><RocketIcon16 class="icon" />Deployments</a> <a class="nav-item" href="#"><GlobeIcon16 class="icon" />Domains</a> <a class="nav-item" href="#"><ChartBarIcon16 class="icon" />Analytics</a> <a class="nav-item" href="#"><ShieldIcon16 class="icon" />Firewall</a> <div class="nav-label">Resources</div> <a class="nav-item" href="#">Pricing</a> <a class="nav-item" href="#">Docs</a> <a class="nav-item" href="#">Changelog</a> </nav> </div> <footer class="dialog-footer"> <a class="btn" href="#">Sign in</a> <a class="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="header-menu" command="close" aria-label="Close the menu"> <XIcon class="icon" /> </button> </dialog></header><main class="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main" tabindex="-1"> <h1 class="heading heading-2xl">The page under the header</h1> <p class="lead"> Scroll, and the bar takes its material. Open Product for the menu; choose Phone for the drawer. </p> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div></main><script setup>import ContrastIcon from '@master/icons-vue/native/16/soft/contrast'import ChevronDownIcon from '@master/icons-vue/native/16/soft/chevron-down'import RocketIcon20 from '@master/icons-vue/native/20/soft/rocket'import GlobeIcon20 from '@master/icons-vue/native/20/soft/globe'import ChartBarIcon20 from '@master/icons-vue/native/20/soft/chart-bar'import ShieldIcon20 from '@master/icons-vue/native/20/soft/shield'import MenuIcon from '@master/icons-vue/native/16/soft/menu'import RocketIcon16 from '@master/icons-vue/native/16/soft/rocket'import GlobeIcon16 from '@master/icons-vue/native/16/soft/globe'import ChartBarIcon16 from '@master/icons-vue/native/16/soft/chart-bar'import ShieldIcon16 from '@master/icons-vue/native/16/soft/shield'import XIcon from '@master/icons-vue/native/16/soft/x'</script><template> <a class="skip" href="#header-main">Skip to content</a> <header class="navbar" style="--navbar-padding-x: 1.5rem"> <a class="navbar-brand" href="#"><ContrastIcon class="icon" />Atlas</a> <nav class="navbar-nav" aria-label="Main"> <button type="button" class="navbar-link" popovertarget="header-product"> Product<ChevronDownIcon class="icon" /> </button> <div class="popover p(4)" id="header-product" popover> <ul class="list list-interactive w(320)"> <li> <a class="list-row" href="#"> <span class="list-media"><RocketIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Deployments</p> <p class="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><GlobeIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Domains</p> <p class="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ChartBarIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Analytics</p> <p class="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ShieldIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Firewall</p> <p class="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a class="navbar-link" href="#">Pricing</a> <a class="navbar-link" href="#">Docs</a> <a class="navbar-link" href="#">Changelog</a> </nav> <div class="navbar-end"> <a class="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a class="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" commandfor="header-menu" command="show-modal" aria-label="Open the menu"> <MenuIcon class="icon" /> </button> </div> <dialog class="dialog dialog-drawer" id="header-menu" closedby="any" aria-label="Menu" style="--dialog-width: 20rem"> <div class="dialog-body flex flex-col gap-md"> <nav class="nav" aria-label="Main, in the menu"> <div class="nav-label">Product</div> <a class="nav-item" href="#"><RocketIcon16 class="icon" />Deployments</a> <a class="nav-item" href="#"><GlobeIcon16 class="icon" />Domains</a> <a class="nav-item" href="#"><ChartBarIcon16 class="icon" />Analytics</a> <a class="nav-item" href="#"><ShieldIcon16 class="icon" />Firewall</a> <div class="nav-label">Resources</div> <a class="nav-item" href="#">Pricing</a> <a class="nav-item" href="#">Docs</a> <a class="nav-item" href="#">Changelog</a> </nav> </div> <footer class="dialog-footer"> <a class="btn" href="#">Sign in</a> <a class="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="header-menu" command="close" aria-label="Close the menu"> <XIcon class="icon" /> </button> </dialog> </header> <main class="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main" tabindex="-1"> <h1 class="heading heading-2xl">The page under the header</h1> <p class="lead"> Scroll, and the bar takes its material. Open Product for the menu; choose Phone for the drawer. </p> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> </main></template>滚动页面,打开“产品”菜单,然后选择“手机”并打开菜单。
区块提供可直接复制的标记,沿用页面自身的文字颜色和字号。预览在 body 上设置 fg-text-body text-sm。每个区块都是尺寸容器,会按自身宽度重排。
#区块组成
- 顶部栏是一个导航栏。 它会吸顶,仅在栏下方有内容时呈现磨砂材质。
- 打开菜单的链接项用按钮实现。 链接和一个
<button popovertarget>都使用navbar-link。“产品”打开菜单,其余各项跳转到对应页面。 - 产品菜单是一个包含列表的弹出层。 它以触发按钮为锚点,遇到视口边缘时翻转位置。每一行都是一个链接,包含标题和一句说明。
- 两个操作中有一个会在空间不足时隐藏。 两者都是采用按钮样式的链接。“登录”是
hidden inline-flex@container(--xl),栏宽达到 36rem 时显示。“开始部署”是唯一的btn-primary,始终显示。 - 只有链接隐藏时才显示切换按钮。 栏宽小于 36rem 时显示
navbar-toggle,这一阈值由导航栏定义。 - 抽屉是一个包含导航区的对话框。 通过
commandfor打开抽屉。点击关闭按钮、点击抽屉外部或按 Esc 均可关闭。抽屉包含与顶部栏相同的链接,底部保留两个操作。
这里以顶部栏为尺寸容器,因此栏内的 @container(…) 工具类以栏宽为准。
#带公告的页眉
横幅位于页眉上方,随页面滚动离开视口,导航栏则保持吸顶。将横幅设为带有 banner-dismissible 的 <dialog open>,访客即可关闭它。
带公告的页眉
<a class="skip" href="#header-main-b">Skip to content</a><div class="banner banner-inverse" role="region" aria-label="Announcement"> <p class="banner-content"> <span class="banner-title">Atlas 4 is here.</span> Faster builds and a new dashboard. <a class="banner-action" href="#">Read the notes</a> </p></div><header class="navbar" style="--navbar-padding-x: 1.5rem"> <a class="navbar-brand" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /><path d="M8 4.3333A3.6667 3.6667 0 0 1 8 11.6667Z" fill="currentColor" stroke="none" /> </svg>Atlas </a> <nav class="navbar-nav" aria-label="Main"> <button type="button" class="navbar-link" popovertarget="header-product-b"> Product<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="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" transform="rotate(90 8 8)" /> </svg> </button> <div class="popover p(4)" id="header-product-b" popover> <ul class="list list-interactive w(320)"> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M10 1.6667C5 5.8333 4.5833 10.8333 7.0833 15.4167H12.9167C15.4167 10.8333 15 5.8333 10 1.6667Z" /><circle cx="10" cy="8.3333" r="1" fill="currentColor" stroke="none" /><path d="M12.5059 15.4167Q12.6134 15.5471 12.7721 15.6266L15.7283 17.1047A0.8249 0.8249 0 0 0 16.9109 16.5023L17.6842 11.8631A0.8257 0.8257 0 0 0 17.4914 11.1839L14.9083 8.2317A0.8274 0.8274 0 0 0 14.1839 7.9561C14.3744 8.793 14.4431 9.6377 14.3995 10.4832L14.5438 9.7135L16.4181 11.8557L15.7727 15.7292L13.6179 14.6519L13.9005 13.1446C13.6551 13.9094 13.3247 14.6686 12.9167 15.4167H12.5059ZM5.8161 7.9561A0.8199 0.8199 0 0 0 5.0917 8.2318L2.5086 11.1839A0.8257 0.8257 0 0 0 2.3158 11.8631L3.089 16.5023A0.825 0.825 0 0 0 4.2717 17.1047L7.2279 15.6266Q7.3866 15.5471 7.4941 15.4167H7.0833C6.6753 14.6686 6.3449 13.9094 6.0995 13.1446L6.3821 14.6519L4.2274 15.7292L3.5818 11.8557L5.4562 9.7135L5.6005 10.4832C5.5569 9.6377 5.6256 8.793 5.8161 7.9561Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M8.3333 18.75L11.6667 18.75" /> </svg> </span> <div class="list-body"> <p class="list-title">Deployments</p> <p class="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="10" cy="10" r="7.5" /><path d="M10.9634 2.5621A7.504 7.504 0 0 0 9.0366 2.5621Q7.6452 3.9922 6.8517 5.7596Q6.0678 7.5056 5.9561 9.375H2.5261A7.4963 7.4963 0 0 0 2.5261 10.625H5.9561Q6.0678 12.4944 6.8517 14.2404Q7.6452 16.0078 9.0366 17.4378A7.492 7.492 0 0 0 10.9634 17.4378Q12.3547 16.0078 13.1483 14.2404Q13.9322 12.4944 14.0439 10.625H17.4739A7.4963 7.4963 0 0 0 17.4739 9.375H14.0439Q13.9322 7.5056 13.1483 5.7596Q12.3547 3.9922 10.9634 2.5621ZM12.0079 6.2716Q12.6818 7.7726 12.7913 9.375H7.2087Q7.3182 7.7726 7.9921 6.2716Q8.7137 4.6643 10 3.3652Q11.2863 4.6643 12.0079 6.2716ZM7.9921 13.7284Q7.3182 12.2274 7.2087 10.625H12.7913Q12.6818 12.2274 12.0079 13.7284Q11.2863 15.3357 10 16.6348Q8.7137 15.3357 7.9921 13.7284Z" fill="currentColor" stroke="none" fill-rule="evenodd" /> </svg> </span> <div class="list-body"> <p class="list-title">Domains</p> <p class="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <rect x="3" y="10" width="3" height="7.5" rx="0.75" /><rect x="8.5" y="4" width="3" height="13.5" rx="0.75" /><rect x="14" y="7.5" width="3" height="10" rx="0.75" /> </svg> </span> <div class="list-body"> <p class="list-title">Analytics</p> <p class="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M9.6667 2.6667Q10 2.5 10.3333 2.6667C12.0833 4 14.5833 4.75 16.3333 5Q16.6667 5 16.6667 5.3333V9.1667C16.6667 13.3333 14.1667 16.25 10.3333 17.4Q10 17.5 9.6667 17.4C5.8333 16.25 3.3333 13.3333 3.3333 9.1667V5.3333Q3.3333 5 3.6667 5C5.4167 4.75 7.9167 4 9.6667 2.6667Z" /> </svg> </span> <div class="list-body"> <p class="list-title">Firewall</p> <p class="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a class="navbar-link" href="#">Pricing</a> <a class="navbar-link" href="#">Docs</a> <a class="navbar-link" href="#">Changelog</a> </nav> <div class="navbar-end"> <a class="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a class="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" commandfor="header-menu-b" command="show-modal" aria-label="Open the menu"> <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="M3 5.5L13 5.5" /><path d="M3 10.5L13 10.5" /> </svg> </button> </div> <dialog class="dialog dialog-drawer" id="header-menu-b" closedby="any" aria-label="Menu" style="--dialog-width: 20rem"> <div class="dialog-body flex flex-col gap-md"> <nav class="nav" aria-label="Main, in the menu"> <div class="nav-label">Product</div> <a class="nav-item" href="#"> <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="M8 1.3333C4 4.6667 3.6667 8.6667 5.6667 12.3333H10.3333C12.3333 8.6667 12 4.6667 8 1.3333Z" /><circle cx="8" cy="6.6667" r="0.85" fill="currentColor" stroke="none" /><path d="M10.016 12.3333Q10.1079 12.4463 10.2446 12.5147L12.5342 13.6594A0.6999 0.6999 0 0 0 13.5377 13.1484L14.1443 9.5091Q14.1989 9.1824 13.9807 8.9328L11.9808 6.6473A0.7011 0.7011 0 0 0 11.3582 6.4146C11.5022 7.0678 11.5536 7.7269 11.5195 8.3865L11.635 7.7707L13.1346 9.4845L12.6181 12.5833L10.8942 11.7215L11.1203 10.5157C10.924 11.1275 10.6597 11.7349 10.3333 12.3333H10.016ZM4.6418 6.4146A0.6958 0.6958 0 0 0 4.0192 6.6473L2.0193 8.9328Q1.8012 9.1824 1.8557 9.5091L2.4623 13.1484A0.6999 0.6999 0 0 0 3.4658 13.6594L5.7554 12.5147Q5.8921 12.4463 5.984 12.3333H5.6667C5.3403 11.7349 5.076 11.1275 4.8797 10.5157L5.1058 11.7215L3.3819 12.5833L2.8654 9.4845L4.365 7.7707L4.4805 8.3865C4.4464 7.7269 4.4978 7.0678 4.6418 6.4146Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M6.6667 15L9.3333 15" /> </svg>Deployments </a> <a class="nav-item" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /><path d="M8.7707 2.0497A6.0005 6.0005 0 0 0 7.2293 2.0497Q6.1162 3.1938 5.4813 4.6077Q4.8542 6.0044 4.7648 7.5H2.0209A5.9913 5.9913 0 0 0 2.0209 8.5H4.7648Q4.8542 9.9956 5.4813 11.3923Q6.1162 12.8062 7.2293 13.9503A6.0005 6.0005 0 0 0 8.7707 13.9503Q9.8838 12.8062 10.5187 11.3923Q11.1458 9.9956 11.2352 8.5H13.9791A5.9913 5.9913 0 0 0 13.9791 7.5H11.2352Q11.1458 6.0044 10.5187 4.6077Q9.8838 3.1938 8.7707 2.0497ZM9.6064 5.0173Q10.1455 6.2181 10.2331 7.5H5.7669Q5.8545 6.2181 6.3936 5.0173Q6.971 3.7314 8 2.6921Q9.029 3.7314 9.6064 5.0173ZM6.3936 10.9827Q5.8545 9.7819 5.7669 8.5H10.2331Q10.1455 9.7819 9.6064 10.9827Q9.029 12.2686 8 13.3079Q6.971 12.2686 6.3936 10.9827Z" fill="currentColor" stroke="none" fill-rule="evenodd" /> </svg>Domains </a> <a class="nav-item" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <rect x="2" y="8" width="2.5" height="6" rx="0.75" /><rect x="6.75" y="3" width="2.5" height="11" rx="0.75" /><rect x="11.5" y="6" width="2.5" height="8" rx="0.75" /> </svg>Analytics </a> <a class="nav-item" href="#"> <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="M7.7333 2.1333Q8 2 8.2667 2.1333C9.6667 3.2 11.6667 3.8 13.0667 4Q13.3333 4 13.3333 4.2667V7.3333C13.3333 10.6667 11.3333 13 8.2667 13.92Q8 14 7.7333 13.92C4.6667 13 2.6667 10.6667 2.6667 7.3333V4.2667Q2.6667 4 2.9333 4C4.3333 3.8 6.3333 3.2 7.7333 2.1333Z" /> </svg>Firewall </a> <div class="nav-label">Resources</div> <a class="nav-item" href="#">Pricing</a> <a class="nav-item" href="#">Docs</a> <a class="nav-item" href="#">Changelog</a> </nav> </div> <footer class="dialog-footer"> <a class="btn" href="#">Sign in</a> <a class="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="header-menu-b" command="close" aria-label="Close the menu"> <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="M4 4L12 12" /><path d="M4 12L12 4" /> </svg> </button> </dialog></header><main class="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main-b" tabindex="-1"> <h1 class="heading heading-2xl">An announcement over the header</h1> <p class="lead">The banner scrolls away with the page; the bar stays.</p> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div></main>import ContrastIcon from '@master/icons-react/native/16/soft/contrast'import ChevronDownIcon from '@master/icons-react/native/16/soft/chevron-down'import RocketIcon20 from '@master/icons-react/native/20/soft/rocket'import GlobeIcon20 from '@master/icons-react/native/20/soft/globe'import ChartBarIcon20 from '@master/icons-react/native/20/soft/chart-bar'import ShieldIcon20 from '@master/icons-react/native/20/soft/shield'import MenuIcon from '@master/icons-react/native/16/soft/menu'import RocketIcon16 from '@master/icons-react/native/16/soft/rocket'import GlobeIcon16 from '@master/icons-react/native/16/soft/globe'import ChartBarIcon16 from '@master/icons-react/native/16/soft/chart-bar'import ShieldIcon16 from '@master/icons-react/native/16/soft/shield'import XIcon from '@master/icons-react/native/16/soft/x'<> <a className="skip" href="#header-main-b">Skip to content</a> <div className="banner banner-inverse" role="region" aria-label="Announcement"> <p className="banner-content"> <span className="banner-title">Atlas 4 is here.</span> Faster builds and a new dashboard. <a className="banner-action" href="#">Read the notes</a> </p> </div> <header className="navbar" style={{ '--navbar-padding-x': '1.5rem' } as React.CSSProperties}> <a className="navbar-brand" href="#"><ContrastIcon className="icon" />Atlas</a> <nav className="navbar-nav" aria-label="Main"> <button type="button" className="navbar-link" popoverTarget="header-product-b"> Product<ChevronDownIcon className="icon" /> </button> <div className="popover p(4)" id="header-product-b" popover=""> <ul className="list list-interactive w(320)"> <li> <a className="list-row" href="#"> <span className="list-media"><RocketIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Deployments</p> <p className="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a className="list-row" href="#"> <span className="list-media"><GlobeIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Domains</p> <p className="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a className="list-row" href="#"> <span className="list-media"><ChartBarIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Analytics</p> <p className="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a className="list-row" href="#"> <span className="list-media"><ShieldIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Firewall</p> <p className="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a className="navbar-link" href="#">Pricing</a> <a className="navbar-link" href="#">Docs</a> <a className="navbar-link" href="#">Changelog</a> </nav> <div className="navbar-end"> <a className="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a className="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" className="btn btn-quiet btn-square btn-sm navbar-toggle" {...{ commandfor: 'header-menu-b', command: 'show-modal' }} aria-label="Open the menu"> <MenuIcon className="icon" /> </button> </div> <dialog className="dialog dialog-drawer" id="header-menu-b" closedby="any" aria-label="Menu" style={{ '--dialog-width': '20rem' } as React.CSSProperties}> <div className="dialog-body flex flex-col gap-md"> <nav className="nav" aria-label="Main, in the menu"> <div className="nav-label">Product</div> <a className="nav-item" href="#"><RocketIcon16 className="icon" />Deployments</a> <a className="nav-item" href="#"><GlobeIcon16 className="icon" />Domains</a> <a className="nav-item" href="#"><ChartBarIcon16 className="icon" />Analytics</a> <a className="nav-item" href="#"><ShieldIcon16 className="icon" />Firewall</a> <div className="nav-label">Resources</div> <a className="nav-item" href="#">Pricing</a> <a className="nav-item" href="#">Docs</a> <a className="nav-item" href="#">Changelog</a> </nav> </div> <footer className="dialog-footer"> <a className="btn" href="#">Sign in</a> <a className="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" className="btn btn-quiet btn-square btn-sm dialog-close" {...{ commandfor: 'header-menu-b', command: 'close' }} aria-label="Close the menu"> <XIcon className="icon" /> </button> </dialog> </header> <main className="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main-b" tabIndex={-1}> <h1 className="heading heading-2xl">An announcement over the header</h1> <p className="lead">The banner scrolls away with the page; the bar stays.</p> <div className="sheet p-xl h(240)"></div> <div className="sheet p-xl h(240)"></div> <div className="sheet p-xl h(240)"></div> </main></><script> import ContrastIcon from '@master/icons-svelte/native/16/soft/contrast' import ChevronDownIcon from '@master/icons-svelte/native/16/soft/chevron-down' import RocketIcon20 from '@master/icons-svelte/native/20/soft/rocket' import GlobeIcon20 from '@master/icons-svelte/native/20/soft/globe' import ChartBarIcon20 from '@master/icons-svelte/native/20/soft/chart-bar' import ShieldIcon20 from '@master/icons-svelte/native/20/soft/shield' import MenuIcon from '@master/icons-svelte/native/16/soft/menu' import RocketIcon16 from '@master/icons-svelte/native/16/soft/rocket' import GlobeIcon16 from '@master/icons-svelte/native/16/soft/globe' import ChartBarIcon16 from '@master/icons-svelte/native/16/soft/chart-bar' import ShieldIcon16 from '@master/icons-svelte/native/16/soft/shield' import XIcon from '@master/icons-svelte/native/16/soft/x'</script><a class="skip" href="#header-main-b">Skip to content</a><div class="banner banner-inverse" role="region" aria-label="Announcement"> <p class="banner-content"> <span class="banner-title">Atlas 4 is here.</span> Faster builds and a new dashboard. <a class="banner-action" href="#">Read the notes</a> </p></div><header class="navbar" style="--navbar-padding-x: 1.5rem"> <a class="navbar-brand" href="#"><ContrastIcon class="icon" />Atlas</a> <nav class="navbar-nav" aria-label="Main"> <button type="button" class="navbar-link" popovertarget="header-product-b"> Product<ChevronDownIcon class="icon" /> </button> <div class="popover p(4)" id="header-product-b" popover> <ul class="list list-interactive w(320)"> <li> <a class="list-row" href="#"> <span class="list-media"><RocketIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Deployments</p> <p class="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><GlobeIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Domains</p> <p class="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ChartBarIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Analytics</p> <p class="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ShieldIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Firewall</p> <p class="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a class="navbar-link" href="#">Pricing</a> <a class="navbar-link" href="#">Docs</a> <a class="navbar-link" href="#">Changelog</a> </nav> <div class="navbar-end"> <a class="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a class="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" commandfor="header-menu-b" command="show-modal" aria-label="Open the menu"> <MenuIcon class="icon" /> </button> </div> <dialog class="dialog dialog-drawer" id="header-menu-b" closedby="any" aria-label="Menu" style="--dialog-width: 20rem"> <div class="dialog-body flex flex-col gap-md"> <nav class="nav" aria-label="Main, in the menu"> <div class="nav-label">Product</div> <a class="nav-item" href="#"><RocketIcon16 class="icon" />Deployments</a> <a class="nav-item" href="#"><GlobeIcon16 class="icon" />Domains</a> <a class="nav-item" href="#"><ChartBarIcon16 class="icon" />Analytics</a> <a class="nav-item" href="#"><ShieldIcon16 class="icon" />Firewall</a> <div class="nav-label">Resources</div> <a class="nav-item" href="#">Pricing</a> <a class="nav-item" href="#">Docs</a> <a class="nav-item" href="#">Changelog</a> </nav> </div> <footer class="dialog-footer"> <a class="btn" href="#">Sign in</a> <a class="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="header-menu-b" command="close" aria-label="Close the menu"> <XIcon class="icon" /> </button> </dialog></header><main class="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main-b" tabindex="-1"> <h1 class="heading heading-2xl">An announcement over the header</h1> <p class="lead">The banner scrolls away with the page; the bar stays.</p> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div></main><script setup>import ContrastIcon from '@master/icons-vue/native/16/soft/contrast'import ChevronDownIcon from '@master/icons-vue/native/16/soft/chevron-down'import RocketIcon20 from '@master/icons-vue/native/20/soft/rocket'import GlobeIcon20 from '@master/icons-vue/native/20/soft/globe'import ChartBarIcon20 from '@master/icons-vue/native/20/soft/chart-bar'import ShieldIcon20 from '@master/icons-vue/native/20/soft/shield'import MenuIcon from '@master/icons-vue/native/16/soft/menu'import RocketIcon16 from '@master/icons-vue/native/16/soft/rocket'import GlobeIcon16 from '@master/icons-vue/native/16/soft/globe'import ChartBarIcon16 from '@master/icons-vue/native/16/soft/chart-bar'import ShieldIcon16 from '@master/icons-vue/native/16/soft/shield'import XIcon from '@master/icons-vue/native/16/soft/x'</script><template> <a class="skip" href="#header-main-b">Skip to content</a> <div class="banner banner-inverse" role="region" aria-label="Announcement"> <p class="banner-content"> <span class="banner-title">Atlas 4 is here.</span> Faster builds and a new dashboard. <a class="banner-action" href="#">Read the notes</a> </p> </div> <header class="navbar" style="--navbar-padding-x: 1.5rem"> <a class="navbar-brand" href="#"><ContrastIcon class="icon" />Atlas</a> <nav class="navbar-nav" aria-label="Main"> <button type="button" class="navbar-link" popovertarget="header-product-b"> Product<ChevronDownIcon class="icon" /> </button> <div class="popover p(4)" id="header-product-b" popover> <ul class="list list-interactive w(320)"> <li> <a class="list-row" href="#"> <span class="list-media"><RocketIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Deployments</p> <p class="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><GlobeIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Domains</p> <p class="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ChartBarIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Analytics</p> <p class="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ShieldIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Firewall</p> <p class="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a class="navbar-link" href="#">Pricing</a> <a class="navbar-link" href="#">Docs</a> <a class="navbar-link" href="#">Changelog</a> </nav> <div class="navbar-end"> <a class="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a class="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" commandfor="header-menu-b" command="show-modal" aria-label="Open the menu"> <MenuIcon class="icon" /> </button> </div> <dialog class="dialog dialog-drawer" id="header-menu-b" closedby="any" aria-label="Menu" style="--dialog-width: 20rem"> <div class="dialog-body flex flex-col gap-md"> <nav class="nav" aria-label="Main, in the menu"> <div class="nav-label">Product</div> <a class="nav-item" href="#"><RocketIcon16 class="icon" />Deployments</a> <a class="nav-item" href="#"><GlobeIcon16 class="icon" />Domains</a> <a class="nav-item" href="#"><ChartBarIcon16 class="icon" />Analytics</a> <a class="nav-item" href="#"><ShieldIcon16 class="icon" />Firewall</a> <div class="nav-label">Resources</div> <a class="nav-item" href="#">Pricing</a> <a class="nav-item" href="#">Docs</a> <a class="nav-item" href="#">Changelog</a> </nav> </div> <footer class="dialog-footer"> <a class="btn" href="#">Sign in</a> <a class="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="header-menu-b" command="close" aria-label="Close the menu"> <XIcon class="icon" /> </button> </dialog> </header> <main class="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main-b" tabindex="-1"> <h1 class="heading heading-2xl">An announcement over the header</h1> <p class="lead">The banner scrolls away with the page; the bar stays.</p> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> </main></template>#悬浮式页眉
navbar-floating 为顶部栏设置外边距和表面圆角,并让它从一开始就呈现表面材质。max-w(960) mx-auto 限制顶部栏在宽屏上的宽度。
悬浮式页眉
<a class="skip" href="#header-main-f">Skip to content</a><header class="navbar navbar-floating max-w(960) mx-auto"> <a class="navbar-brand ml-xs" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /><path d="M8 4.3333A3.6667 3.6667 0 0 1 8 11.6667Z" fill="currentColor" stroke="none" /> </svg>Atlas </a> <nav class="navbar-nav" aria-label="Main"> <button type="button" class="navbar-link" popovertarget="header-product-f"> Product<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="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" transform="rotate(90 8 8)" /> </svg> </button> <div class="popover p(4)" id="header-product-f" popover> <ul class="list list-interactive w(320)"> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M10 1.6667C5 5.8333 4.5833 10.8333 7.0833 15.4167H12.9167C15.4167 10.8333 15 5.8333 10 1.6667Z" /><circle cx="10" cy="8.3333" r="1" fill="currentColor" stroke="none" /><path d="M12.5059 15.4167Q12.6134 15.5471 12.7721 15.6266L15.7283 17.1047A0.8249 0.8249 0 0 0 16.9109 16.5023L17.6842 11.8631A0.8257 0.8257 0 0 0 17.4914 11.1839L14.9083 8.2317A0.8274 0.8274 0 0 0 14.1839 7.9561C14.3744 8.793 14.4431 9.6377 14.3995 10.4832L14.5438 9.7135L16.4181 11.8557L15.7727 15.7292L13.6179 14.6519L13.9005 13.1446C13.6551 13.9094 13.3247 14.6686 12.9167 15.4167H12.5059ZM5.8161 7.9561A0.8199 0.8199 0 0 0 5.0917 8.2318L2.5086 11.1839A0.8257 0.8257 0 0 0 2.3158 11.8631L3.089 16.5023A0.825 0.825 0 0 0 4.2717 17.1047L7.2279 15.6266Q7.3866 15.5471 7.4941 15.4167H7.0833C6.6753 14.6686 6.3449 13.9094 6.0995 13.1446L6.3821 14.6519L4.2274 15.7292L3.5818 11.8557L5.4562 9.7135L5.6005 10.4832C5.5569 9.6377 5.6256 8.793 5.8161 7.9561Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M8.3333 18.75L11.6667 18.75" /> </svg> </span> <div class="list-body"> <p class="list-title">Deployments</p> <p class="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="10" cy="10" r="7.5" /><path d="M10.9634 2.5621A7.504 7.504 0 0 0 9.0366 2.5621Q7.6452 3.9922 6.8517 5.7596Q6.0678 7.5056 5.9561 9.375H2.5261A7.4963 7.4963 0 0 0 2.5261 10.625H5.9561Q6.0678 12.4944 6.8517 14.2404Q7.6452 16.0078 9.0366 17.4378A7.492 7.492 0 0 0 10.9634 17.4378Q12.3547 16.0078 13.1483 14.2404Q13.9322 12.4944 14.0439 10.625H17.4739A7.4963 7.4963 0 0 0 17.4739 9.375H14.0439Q13.9322 7.5056 13.1483 5.7596Q12.3547 3.9922 10.9634 2.5621ZM12.0079 6.2716Q12.6818 7.7726 12.7913 9.375H7.2087Q7.3182 7.7726 7.9921 6.2716Q8.7137 4.6643 10 3.3652Q11.2863 4.6643 12.0079 6.2716ZM7.9921 13.7284Q7.3182 12.2274 7.2087 10.625H12.7913Q12.6818 12.2274 12.0079 13.7284Q11.2863 15.3357 10 16.6348Q8.7137 15.3357 7.9921 13.7284Z" fill="currentColor" stroke="none" fill-rule="evenodd" /> </svg> </span> <div class="list-body"> <p class="list-title">Domains</p> <p class="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <rect x="3" y="10" width="3" height="7.5" rx="0.75" /><rect x="8.5" y="4" width="3" height="13.5" rx="0.75" /><rect x="14" y="7.5" width="3" height="10" rx="0.75" /> </svg> </span> <div class="list-body"> <p class="list-title">Analytics</p> <p class="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M9.6667 2.6667Q10 2.5 10.3333 2.6667C12.0833 4 14.5833 4.75 16.3333 5Q16.6667 5 16.6667 5.3333V9.1667C16.6667 13.3333 14.1667 16.25 10.3333 17.4Q10 17.5 9.6667 17.4C5.8333 16.25 3.3333 13.3333 3.3333 9.1667V5.3333Q3.3333 5 3.6667 5C5.4167 4.75 7.9167 4 9.6667 2.6667Z" /> </svg> </span> <div class="list-body"> <p class="list-title">Firewall</p> <p class="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a class="navbar-link" href="#">Pricing</a> <a class="navbar-link" href="#">Docs</a> <a class="navbar-link" href="#">Changelog</a> </nav> <div class="navbar-end"> <a class="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a class="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" commandfor="header-menu-f" command="show-modal" aria-label="Open the menu"> <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="M3 5.5L13 5.5" /><path d="M3 10.5L13 10.5" /> </svg> </button> </div> <dialog class="dialog dialog-drawer" id="header-menu-f" closedby="any" aria-label="Menu" style="--dialog-width: 20rem"> <div class="dialog-body flex flex-col gap-md"> <nav class="nav" aria-label="Main, in the menu"> <div class="nav-label">Product</div> <a class="nav-item" href="#"> <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="M8 1.3333C4 4.6667 3.6667 8.6667 5.6667 12.3333H10.3333C12.3333 8.6667 12 4.6667 8 1.3333Z" /><circle cx="8" cy="6.6667" r="0.85" fill="currentColor" stroke="none" /><path d="M10.016 12.3333Q10.1079 12.4463 10.2446 12.5147L12.5342 13.6594A0.6999 0.6999 0 0 0 13.5377 13.1484L14.1443 9.5091Q14.1989 9.1824 13.9807 8.9328L11.9808 6.6473A0.7011 0.7011 0 0 0 11.3582 6.4146C11.5022 7.0678 11.5536 7.7269 11.5195 8.3865L11.635 7.7707L13.1346 9.4845L12.6181 12.5833L10.8942 11.7215L11.1203 10.5157C10.924 11.1275 10.6597 11.7349 10.3333 12.3333H10.016ZM4.6418 6.4146A0.6958 0.6958 0 0 0 4.0192 6.6473L2.0193 8.9328Q1.8012 9.1824 1.8557 9.5091L2.4623 13.1484A0.6999 0.6999 0 0 0 3.4658 13.6594L5.7554 12.5147Q5.8921 12.4463 5.984 12.3333H5.6667C5.3403 11.7349 5.076 11.1275 4.8797 10.5157L5.1058 11.7215L3.3819 12.5833L2.8654 9.4845L4.365 7.7707L4.4805 8.3865C4.4464 7.7269 4.4978 7.0678 4.6418 6.4146Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M6.6667 15L9.3333 15" /> </svg>Deployments </a> <a class="nav-item" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /><path d="M8.7707 2.0497A6.0005 6.0005 0 0 0 7.2293 2.0497Q6.1162 3.1938 5.4813 4.6077Q4.8542 6.0044 4.7648 7.5H2.0209A5.9913 5.9913 0 0 0 2.0209 8.5H4.7648Q4.8542 9.9956 5.4813 11.3923Q6.1162 12.8062 7.2293 13.9503A6.0005 6.0005 0 0 0 8.7707 13.9503Q9.8838 12.8062 10.5187 11.3923Q11.1458 9.9956 11.2352 8.5H13.9791A5.9913 5.9913 0 0 0 13.9791 7.5H11.2352Q11.1458 6.0044 10.5187 4.6077Q9.8838 3.1938 8.7707 2.0497ZM9.6064 5.0173Q10.1455 6.2181 10.2331 7.5H5.7669Q5.8545 6.2181 6.3936 5.0173Q6.971 3.7314 8 2.6921Q9.029 3.7314 9.6064 5.0173ZM6.3936 10.9827Q5.8545 9.7819 5.7669 8.5H10.2331Q10.1455 9.7819 9.6064 10.9827Q9.029 12.2686 8 13.3079Q6.971 12.2686 6.3936 10.9827Z" fill="currentColor" stroke="none" fill-rule="evenodd" /> </svg>Domains </a> <a class="nav-item" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <rect x="2" y="8" width="2.5" height="6" rx="0.75" /><rect x="6.75" y="3" width="2.5" height="11" rx="0.75" /><rect x="11.5" y="6" width="2.5" height="8" rx="0.75" /> </svg>Analytics </a> <a class="nav-item" href="#"> <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="M7.7333 2.1333Q8 2 8.2667 2.1333C9.6667 3.2 11.6667 3.8 13.0667 4Q13.3333 4 13.3333 4.2667V7.3333C13.3333 10.6667 11.3333 13 8.2667 13.92Q8 14 7.7333 13.92C4.6667 13 2.6667 10.6667 2.6667 7.3333V4.2667Q2.6667 4 2.9333 4C4.3333 3.8 6.3333 3.2 7.7333 2.1333Z" /> </svg>Firewall </a> <div class="nav-label">Resources</div> <a class="nav-item" href="#">Pricing</a> <a class="nav-item" href="#">Docs</a> <a class="nav-item" href="#">Changelog</a> </nav> </div> <footer class="dialog-footer"> <a class="btn" href="#">Sign in</a> <a class="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="header-menu-f" command="close" aria-label="Close the menu"> <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="M4 4L12 12" /><path d="M4 12L12 4" /> </svg> </button> </dialog></header><main class="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main-f" tabindex="-1"> <h1 class="heading heading-2xl">A header that floats</h1> <p class="lead">It keeps a margin from the edges and its material from the start.</p> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div></main>import ContrastIcon from '@master/icons-react/native/16/soft/contrast'import ChevronDownIcon from '@master/icons-react/native/16/soft/chevron-down'import RocketIcon20 from '@master/icons-react/native/20/soft/rocket'import GlobeIcon20 from '@master/icons-react/native/20/soft/globe'import ChartBarIcon20 from '@master/icons-react/native/20/soft/chart-bar'import ShieldIcon20 from '@master/icons-react/native/20/soft/shield'import MenuIcon from '@master/icons-react/native/16/soft/menu'import RocketIcon16 from '@master/icons-react/native/16/soft/rocket'import GlobeIcon16 from '@master/icons-react/native/16/soft/globe'import ChartBarIcon16 from '@master/icons-react/native/16/soft/chart-bar'import ShieldIcon16 from '@master/icons-react/native/16/soft/shield'import XIcon from '@master/icons-react/native/16/soft/x'<> <a className="skip" href="#header-main-f">Skip to content</a> <header className="navbar navbar-floating max-w(960) mx-auto"> <a className="navbar-brand ml-xs" href="#"><ContrastIcon className="icon" />Atlas</a> <nav className="navbar-nav" aria-label="Main"> <button type="button" className="navbar-link" popoverTarget="header-product-f"> Product<ChevronDownIcon className="icon" /> </button> <div className="popover p(4)" id="header-product-f" popover=""> <ul className="list list-interactive w(320)"> <li> <a className="list-row" href="#"> <span className="list-media"><RocketIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Deployments</p> <p className="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a className="list-row" href="#"> <span className="list-media"><GlobeIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Domains</p> <p className="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a className="list-row" href="#"> <span className="list-media"><ChartBarIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Analytics</p> <p className="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a className="list-row" href="#"> <span className="list-media"><ShieldIcon20 className="icon" /></span> <div className="list-body"> <p className="list-title">Firewall</p> <p className="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a className="navbar-link" href="#">Pricing</a> <a className="navbar-link" href="#">Docs</a> <a className="navbar-link" href="#">Changelog</a> </nav> <div className="navbar-end"> <a className="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a className="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" className="btn btn-quiet btn-square btn-sm navbar-toggle" {...{ commandfor: 'header-menu-f', command: 'show-modal' }} aria-label="Open the menu"> <MenuIcon className="icon" /> </button> </div> <dialog className="dialog dialog-drawer" id="header-menu-f" closedby="any" aria-label="Menu" style={{ '--dialog-width': '20rem' } as React.CSSProperties}> <div className="dialog-body flex flex-col gap-md"> <nav className="nav" aria-label="Main, in the menu"> <div className="nav-label">Product</div> <a className="nav-item" href="#"><RocketIcon16 className="icon" />Deployments</a> <a className="nav-item" href="#"><GlobeIcon16 className="icon" />Domains</a> <a className="nav-item" href="#"><ChartBarIcon16 className="icon" />Analytics</a> <a className="nav-item" href="#"><ShieldIcon16 className="icon" />Firewall</a> <div className="nav-label">Resources</div> <a className="nav-item" href="#">Pricing</a> <a className="nav-item" href="#">Docs</a> <a className="nav-item" href="#">Changelog</a> </nav> </div> <footer className="dialog-footer"> <a className="btn" href="#">Sign in</a> <a className="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" className="btn btn-quiet btn-square btn-sm dialog-close" {...{ commandfor: 'header-menu-f', command: 'close' }} aria-label="Close the menu"> <XIcon className="icon" /> </button> </dialog> </header> <main className="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main-f" tabIndex={-1}> <h1 className="heading heading-2xl">A header that floats</h1> <p className="lead">It keeps a margin from the edges and its material from the start.</p> <div className="sheet p-xl h(240)"></div> <div className="sheet p-xl h(240)"></div> <div className="sheet p-xl h(240)"></div> </main></><script> import ContrastIcon from '@master/icons-svelte/native/16/soft/contrast' import ChevronDownIcon from '@master/icons-svelte/native/16/soft/chevron-down' import RocketIcon20 from '@master/icons-svelte/native/20/soft/rocket' import GlobeIcon20 from '@master/icons-svelte/native/20/soft/globe' import ChartBarIcon20 from '@master/icons-svelte/native/20/soft/chart-bar' import ShieldIcon20 from '@master/icons-svelte/native/20/soft/shield' import MenuIcon from '@master/icons-svelte/native/16/soft/menu' import RocketIcon16 from '@master/icons-svelte/native/16/soft/rocket' import GlobeIcon16 from '@master/icons-svelte/native/16/soft/globe' import ChartBarIcon16 from '@master/icons-svelte/native/16/soft/chart-bar' import ShieldIcon16 from '@master/icons-svelte/native/16/soft/shield' import XIcon from '@master/icons-svelte/native/16/soft/x'</script><a class="skip" href="#header-main-f">Skip to content</a><header class="navbar navbar-floating max-w(960) mx-auto"> <a class="navbar-brand ml-xs" href="#"><ContrastIcon class="icon" />Atlas</a> <nav class="navbar-nav" aria-label="Main"> <button type="button" class="navbar-link" popovertarget="header-product-f"> Product<ChevronDownIcon class="icon" /> </button> <div class="popover p(4)" id="header-product-f" popover> <ul class="list list-interactive w(320)"> <li> <a class="list-row" href="#"> <span class="list-media"><RocketIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Deployments</p> <p class="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><GlobeIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Domains</p> <p class="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ChartBarIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Analytics</p> <p class="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ShieldIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Firewall</p> <p class="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a class="navbar-link" href="#">Pricing</a> <a class="navbar-link" href="#">Docs</a> <a class="navbar-link" href="#">Changelog</a> </nav> <div class="navbar-end"> <a class="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a class="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" commandfor="header-menu-f" command="show-modal" aria-label="Open the menu"> <MenuIcon class="icon" /> </button> </div> <dialog class="dialog dialog-drawer" id="header-menu-f" closedby="any" aria-label="Menu" style="--dialog-width: 20rem"> <div class="dialog-body flex flex-col gap-md"> <nav class="nav" aria-label="Main, in the menu"> <div class="nav-label">Product</div> <a class="nav-item" href="#"><RocketIcon16 class="icon" />Deployments</a> <a class="nav-item" href="#"><GlobeIcon16 class="icon" />Domains</a> <a class="nav-item" href="#"><ChartBarIcon16 class="icon" />Analytics</a> <a class="nav-item" href="#"><ShieldIcon16 class="icon" />Firewall</a> <div class="nav-label">Resources</div> <a class="nav-item" href="#">Pricing</a> <a class="nav-item" href="#">Docs</a> <a class="nav-item" href="#">Changelog</a> </nav> </div> <footer class="dialog-footer"> <a class="btn" href="#">Sign in</a> <a class="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="header-menu-f" command="close" aria-label="Close the menu"> <XIcon class="icon" /> </button> </dialog></header><main class="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main-f" tabindex="-1"> <h1 class="heading heading-2xl">A header that floats</h1> <p class="lead">It keeps a margin from the edges and its material from the start.</p> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div></main><script setup>import ContrastIcon from '@master/icons-vue/native/16/soft/contrast'import ChevronDownIcon from '@master/icons-vue/native/16/soft/chevron-down'import RocketIcon20 from '@master/icons-vue/native/20/soft/rocket'import GlobeIcon20 from '@master/icons-vue/native/20/soft/globe'import ChartBarIcon20 from '@master/icons-vue/native/20/soft/chart-bar'import ShieldIcon20 from '@master/icons-vue/native/20/soft/shield'import MenuIcon from '@master/icons-vue/native/16/soft/menu'import RocketIcon16 from '@master/icons-vue/native/16/soft/rocket'import GlobeIcon16 from '@master/icons-vue/native/16/soft/globe'import ChartBarIcon16 from '@master/icons-vue/native/16/soft/chart-bar'import ShieldIcon16 from '@master/icons-vue/native/16/soft/shield'import XIcon from '@master/icons-vue/native/16/soft/x'</script><template> <a class="skip" href="#header-main-f">Skip to content</a> <header class="navbar navbar-floating max-w(960) mx-auto"> <a class="navbar-brand ml-xs" href="#"><ContrastIcon class="icon" />Atlas</a> <nav class="navbar-nav" aria-label="Main"> <button type="button" class="navbar-link" popovertarget="header-product-f"> Product<ChevronDownIcon class="icon" /> </button> <div class="popover p(4)" id="header-product-f" popover> <ul class="list list-interactive w(320)"> <li> <a class="list-row" href="#"> <span class="list-media"><RocketIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Deployments</p> <p class="list-description">Every push gets its own address.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><GlobeIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Domains</p> <p class="list-description">Certificates that renew themselves.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ChartBarIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Analytics</p> <p class="list-description">Traffic and speed, without cookies.</p> </div> </a> </li> <li> <a class="list-row" href="#"> <span class="list-media"><ShieldIcon20 class="icon" /></span> <div class="list-body"> <p class="list-title">Firewall</p> <p class="list-description">Rules at the edge, in every region.</p> </div> </a> </li> </ul> </div> <a class="navbar-link" href="#">Pricing</a> <a class="navbar-link" href="#">Docs</a> <a class="navbar-link" href="#">Changelog</a> </nav> <div class="navbar-end"> <a class="btn btn-quiet btn-sm hidden inline-flex@container(--xl)" href="#">Sign in</a> <a class="btn btn-primary btn-sm" href="#">Start deploying</a> <button type="button" class="btn btn-quiet btn-square btn-sm navbar-toggle" commandfor="header-menu-f" command="show-modal" aria-label="Open the menu"> <MenuIcon class="icon" /> </button> </div> <dialog class="dialog dialog-drawer" id="header-menu-f" closedby="any" aria-label="Menu" style="--dialog-width: 20rem"> <div class="dialog-body flex flex-col gap-md"> <nav class="nav" aria-label="Main, in the menu"> <div class="nav-label">Product</div> <a class="nav-item" href="#"><RocketIcon16 class="icon" />Deployments</a> <a class="nav-item" href="#"><GlobeIcon16 class="icon" />Domains</a> <a class="nav-item" href="#"><ChartBarIcon16 class="icon" />Analytics</a> <a class="nav-item" href="#"><ShieldIcon16 class="icon" />Firewall</a> <div class="nav-label">Resources</div> <a class="nav-item" href="#">Pricing</a> <a class="nav-item" href="#">Docs</a> <a class="nav-item" href="#">Changelog</a> </nav> </div> <footer class="dialog-footer"> <a class="btn" href="#">Sign in</a> <a class="btn btn-primary" href="#">Start deploying</a> </footer> <button type="button" class="btn btn-quiet btn-square btn-sm dialog-close" commandfor="header-menu-f" command="close" aria-label="Close the menu"> <XIcon class="icon" /> </button> </dialog> </header> <main class="max-w(720) mx-auto px-lg py-3xl flex flex-col gap-md" id="header-main-f" tabindex="-1"> <h1 class="heading heading-2xl">A header that floats</h1> <p class="lead">It keeps a margin from the edges and its material from the start.</p> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> <div class="sheet p-xl h(240)"></div> </main></template>#无障碍
- 页面的第一个元素是指向
<main>的跳过链接。目标带有tabindex="-1",跳转时焦点也会移过去。此链接用于跳过页眉。 - 页眉使用
<header>,其中的链接位于带标签的<nav>中。抽屉内另有一个<nav>,使用不同的标签。 - “产品”项使用按钮,因为它只负责打开菜单,不会跳转页面。弹出层内是一个链接列表,可按 Tab 访问,按 Escape 关闭。
- 在顶部栏和抽屉中,都为当前页面对应的链接设置
aria-current="page"。 - 在根元素上设置
scroll-padding-top: 3.5rem,避免跳转到标题时标题被顶部栏遮住。