HTML menu type 屬性
實例
帶有兩個菜單按鈕("File" 和"Edit")的工具欄,每個按鈕都是一個帶有一系列選項的下拉菜單:
<menu type="toolbar">
<li>
<menu label="File">
<button type="button" onclick="file_new()">New...</button>
<button type="button" onclick="file_open()">Open...</button>
<button type="button" onclick="file_save()">Save</button>
</menu>
</li>
<li>
<menu label="Edit">
<button type="button" onclick="edit_cut()">Cut</button>
<button type="button" onclick="edit_copy()">Copy</button>
<button type="button" onclick="edit_paste()">Paste</button>
</menu>
</li>
</menu>
<li>
<menu label="File">
<button type="button" onclick="file_new()">New...</button>
<button type="button" onclick="file_open()">Open...</button>
<button type="button" onclick="file_save()">Save</button>
</menu>
</li>
<li>
<menu label="Edit">
<button type="button" onclick="edit_cut()">Cut</button>
<button type="button" onclick="edit_copy()">Copy</button>
<button type="button" onclick="edit_paste()">Paste</button>
</menu>
</li>
</menu>
嘗試一下»
瀏覽器支持
目前幾乎沒有主流瀏覽器支持type 屬性。
定義和用法
type 屬性規定菜單的類型。
HTML 4.01 與HTML5之間的差異
在HTML5 中,重定義了<menu> 元素,且新增了type 屬性。
語法
<menu type="list|context|toolbar">
屬性值
值 | 描述 |
---|---|
list | 默认。规定一个列表菜单。一个用户可执行或激活的命令列表(li 元素)。 |
context | 规定一个上下文菜单。菜单必须在用户与命令进行交互之前被激活。 |
toolbar | 规定一个工具栏菜单。主动式命令,允许用户立即与命令进行交互。 |
HTML <menu>標籤