Material Design Lite - 菜单
MDL 提供了一系列 CSS 类,用于应用各种预定义的视觉和行为增强功能并显示不同类型的菜单。下表列出了可用的类及其效果
Sr.No. | 类名 &描述 |
---|---|
1 | mdl-button 将按钮标识为 MDL 组件,并且是按钮元素所必需的。 |
2 | mdl-js-button 将基本 MDL 行为设置为按钮,并且是按钮元素所必需的。 |
3 | mdl-button--icon 将图标设置为按钮,并且是按钮元素所必需的元素。 |
4 | material-icons 将 span 标识为材料图标,并且是内联元素上必需的。 |
5 | mdl-menu 将无序列表容器标识为 MDL 组件,并且是 ul 元素上必需的。 |
6 | mdl-js-menu 将基本 MDL 行为设置为菜单,并且是 ul 上必需的元素。 |
7 | mdl-menu__item 将按钮标识为 MDL 菜单选项并设置基本 MDL 行为,列表项元素上必需。 |
8 | mdl-js-ripple-effect 将涟漪点击效果设置为选项链接,是可选的;无序列表元素上必需。 |
9 | mdl-menu--top-left 设置按钮上方的菜单位置,将菜单左边缘与按钮对齐,是可选的;无序列表元素上必需。 |
10 | (无) 默认情况下,菜单位于按钮下方,与按钮左边缘对齐。 |
11 | mdl-menu--top-right 菜单位于按钮上方,与按钮右边缘对齐,可选,位于无序列表元素上。 |
12 | mdl-menu--bottom-right 菜单位于按钮下方,与按钮右边缘对齐,可选,并位于无序列表元素上。 |
示例
以下示例将帮助您了解如何使用 mdl-spinner 类来显示不同类型的微调器。
mdl_menu.htm
<html> <head> <script src = "https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js"> </script> <link rel = "stylesheet" href = "https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css"> <link rel = "stylesheet" href = "https://fonts.googleapis.com/icon?family=Material+Icons"> <style> .container { position: relative; width: 200px; } .background { background: white; height: 148px; width: 100%; } .bar { box-sizing: border-box; background: #BBBBBB; color: white; width: 100%; height: 64px; padding: 16px; } .wrapper { box-sizing: border-box; position: absolute; right: 16px; } </style> </head> <body> <table> <tr><td>Lower Left Menu</td><td>Lower Right Menu</td><td>Top Left Menu</td> <td>Top Right Menu</td></tr> <tr> <td> <div class = "container mdl-shadow--2dp"> <div class = "bar"> <button id = "demo_menu-lower-left" class = "mdl-button mdl-js-button mdl-button--icon" data-upgraded = ",MaterialButton"> <i class = "material-icons">more_vert</i> </button> <ul class = "mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect" for = "demo_menu-lower-left"> <li class = "mdl-menu__item">Item #1</li> <li class = "mdl-menu__item">Item #2</li> <li disabled class = "mdl-menu__item">Disabled Item</li> </ul> </div> <div class = "background"></div> </div> </td> <td> <div class = "container mdl-shadow--2dp"> <div class = "bar"> <div class = "wrapper"> <button id = "demo_menu-lower-right" class = "mdl-button mdl-js-button mdl-button--icon" data-upgraded = ",MaterialButton"> <i class = "material-icons">more_vert</i> </button> <ul class = "mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for = "demo_menu-lower-right"> <li class = "mdl-menu__item">Item #1</li> <li class = "mdl-menu__item">Item #2</li> <li disabled class = "mdl-menu__item">Disabled Item</li> </ul> </div> </div> <div class = "background"></div> </div> </td> <td> <div class = "container mdl-shadow--2dp"> <div class = "background"></div> <div class = "bar"> <button id = "demo_menu-top-left" class = "mdl-button mdl-js-button mdl-button--icon" data-upgraded = ",MaterialButton"> <i class = "material-icons">more_vert</i> </button> <ul class = "mdl-menu mdl-menu--top-left mdl-js-menu mdl-js-ripple-effect" for = "demo_menu-top-left"> <li class = "mdl-menu__item">Item #1</li> <li class = "mdl-menu__item">Item #2</li> <li disabled class = "mdl-menu__item">Disabled Item</li> </ul> </div> </div> </td> <td> <div class = "container mdl-shadow--2dp"> <div class = "background"></div> <div class = "bar"> <div class = "wrapper"> <button id = "demo_menu-top-right" class = "mdl-button mdl-js-button mdl-button--icon" data-upgraded = ",MaterialButton"> <i class = "material-icons">more_vert</i> </button> <ul class = "mdl-menu mdl-menu--top-right mdl-js-menu mdl-js-ripple-effect" for = "demo_menu-top-right"> <li class = "mdl-menu__item">Item #1</li> <li class = "mdl-menu__item">Item #2</li> <li disabled class = "mdl-menu__item">Disabled Item</li> </ul> </div> </div> </div> </td> </tr> </table> </body> </html>
结果
验证结果。