dropdown
列表页 通用列表页:标题、工具栏和行,桌面和移动端都适用。
一个零 JavaScript 的折叠块:一个 summary 按钮,下面是一板普通链接。把它放在一行里,挨着它作用的对象,不要让它独占一行。
每个示例都能真实操作,但其中的链接不会跳转到任何地方。 HTML 显示可复制的标记。
已应用一项选择的筛选菜单
<div rst-box-head >
<h2 >文章</h2 >
<details rst-dropdown name ="rst-menus" >
<summary rst-btn aria-label ="文章排序:最新在前" >
最新
<svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><path d ="m6 9 6 6 6-6" /></svg >
</summary >
<div rst-dropdown-menu >
<a href ="/posts?sort=newest" aria-current ="true" >最新 <svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><path d ="M20 6 9 17l-5-5" /></svg ></a >
<a href ="/posts?sort=oldest" >最早</a >
<a href ="/posts?sort=title" >按标题</a >
</div >
</details >
</div >
在应用里,这会到达 /posts?sort=newest, /posts?sort=oldest, /posts?sort=title。在这里,它的链接和表单哪儿也不去。
藏在页眉溢出菜单和列表工具栏筛选背后的 details/summary 菜单,外加一枚可移除的已应用筛选标签。
<div rst-list >
<div rst-lbar >
<details rst-dropdown name ="rst-menus" >
<summary >
筛选
<span rst-caret aria-hidden ="true" >
<svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><path d ="m6 9 6 6 6-6" /></svg >
</span >
<span class ="rst-sr-only" >筛选订单:已付款</span >
</summary >
<div rst-dropdown-menu >
<a aria-current ="true" href ="/orders?status=paid" >已付款</a >
<details rst-menu-group name ="rst-menus-price" open >
<summary >价格</summary >
<div >
<a href ="/orders?price=free" >免费</a >
</div >
</details >
</div >
</details >
<span rst-ftok >
<span rst-ftok-k >已付款</span >
<a href ="/orders" aria-label ="移除筛选条件:已付款" >✕</a >
</span >
</div >
</div >
在应用里,这会到达 /orders, /orders?price=free, /orders?status=paid。在这里,它的链接和表单哪儿也不去。