示例工程 31-modals-dropdowns
31-modals-dropdowns/demo-01-dropdown/index.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>两种下拉</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>两种下拉</h1>
<section>
<h2>details</h2>
<details class="menu">
<summary>排序</summary>
<ul>
<li><a href="#top">最新</a></li>
<li><a href="#top">最热</a></li>
<li><a href="#top">价格</a></li>
</ul>
</details>
<p class="hint">无 JS;点外面不关闭;适合简单菜单。</p>
</section>
<section>
<h2>popover</h2>
<button type="button" class="btn" popovertarget="panel">筛选</button>
<div id="panel" popover class="panel">
<p>Esc 关闭、点外部关闭。</p>
<button type="button" class="btn" popovertarget="panel">关闭</button>
</div>
<p class="hint">非模态;进入 top layer。</p>
</section>
</body>
</html>