MDL提供了一系列CSS类来应用各种预定义的视觉和行为
增强功能,并将不同类型的复选框显示为开关.下表列出了可用的类及其效果.
Sr.No. | Class Name&描述 |
---|---|
1 | mdl-switch 将标签标识为MDL组件,并且在标签元素上是必需的. |
2 | mdl-js-switch 将基本MDL行为设置为标签,并且在标签元素上是必需的. |
3 | mdl-switch__input 设置要切换的基本MDL行为,并且在输入元素(开关)上是必需的. |
4 | mdl-switch__label 将基本MDL行为设置为标题,并且在输入元素(标题)上是必需的. |
5 | mdl -js纹波效应 设置涟漪点击效果并且是可选的;继承标签元素而不是输入元素(开关). |
以下示例将帮助您了解使用mdl-switch类和
不同类型的复选框作为开关.
<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"> </head> <body> <table> <tr><td>On Switch</td><td>Off Switch</td> <td>Disabled Switch</td></tr> <tr> <td> <label class = "mdl-switch mdl-js-switch mdl-js-ripple-effect" for = "switch-1"> <input type = "checkbox" id = "switch-1" class = "mdl-switch__input" checked> </label> </td> <td> <label class = "mdl-switch mdl-js-switch mdl-js-ripple-effect" for = "switch-2"> <input type = "checkbox" id = "switch-2" class = "mdl-switch__input"> </label> </td> <td> <label class = "mdl-switch mdl-js-switch mdl-js-ripple-effect" for = "switch-2"> <input type = "checkbox" id = "switch-2" class = "mdl-switch__input" disabled> </label> </td> </tr> </table> </body> </html>
验证结果.