<menu>:菜单元素
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
尝试一下
属性
这个元素只包含全局属性。
使用说明
示例
工具栏
在这个示例中,使用 <menu>
元素创建了一个编辑应用程序的工具栏。
HTML
html
<menu>
<li><button onclick="copy()">复制</button></li>
<li><button onclick="cut()">剪切</button></li>
<li><button onclick="paste()">粘贴</button></li>
</menu>
请注意,这在功能上与以下内容没有区别:
html
<ul>
<li><button onclick="copy()">复制</button></li>
<li><button onclick="cut()">剪切</button></li>
<li><button onclick="paste()">粘贴</button></li>
</ul>
CSS
css
menu,
ul {
display: flex;
list-style: none;
padding: 0;
width: 400px;
}
li {
flex-grow: 1;
}
button {
width: 100%;
}
结果
技术概要
规范
Specification |
---|
HTML # the-menu-element |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
menu |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.