- Material Design Lite 教程
- MDL - 主頁
- MDL - 概述
- MDL - 環境設定
- MDL - 佈局
- MDL - 網格
- MDL - 選項卡
- MDL - 頁尾
- MDL - 徽章
- MDL - 按鈕
- MDL - 卡片
- MDL - 進度條
- MDL - 旋轉器
- MDL - 選單
- MDL - 滑塊
- MDL - 複選框
- MDL - 單選按鈕
- MDL - 圖示
- MDL - 開關
- MDL - 資料表
- MDL - 文字框
- MDL - 工具提示
- Material Design Lite 資源
- MDL - 快速指南
- MDL - 有用資源
- MDL - 討論
Material Design Lite - 單選按鈕
MDL 提供一系列 CSS 類別來應用各種預定義的視覺和行為增強功能,並顯示不同型別的單選按鈕。下表列出了可用的類別及其功能。
| 序號。 | 類別名和描述 |
|---|---|
| 1 | mdl-radio 將標籤標識為 MDL 元件,並且在標籤元素上必需。 |
| 2 | mdl-js-radio 設定標籤的基本 MDL 行為,並且在標籤元素上必需。 |
| 3 | mdl-radio__button 設定基本 MDL 行為到單選按鈕中,並且在輸入元素(單選按鈕)中必需。 |
| 4 | mdl-radio__label 設定基本 MDL 行為到標題中,並且在 span 元素(標題)中必需。 |
| 5 | mdl-js-ripple-effect 設定波紋點選效果,並且是可選的;在標籤元素上使用,而不是在輸入元素(單選按鈕)上使用。 |
示例
以下示例將幫助你瞭解 mdl-slider 類別來顯示不同型別的單選按鈕的方法。
mdl_radio.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">
<script langauage = "javascript">
function showMessage(value) {
document.getElementById("message").innerHTML = value;
}
</script>
</head>
<body>
<table>
<tr><td>Default Radio Button</td><td>Radio Button with Ripple Effect</td>
<td>Disabled Radio Button</td></tr>
<tr>
<td>
<label class = "mdl-radio mdl-js-radio" for = "option1">
<input type = "radio" id = "option1" name = "gender"
class = "mdl-radio__button" checked>
<span class = "mdl-radio__label">Male</span>
</label>
</td>
<td>
<label class = "mdl-radio mdl-js-radio mdl-js-ripple-effect"
for = "option2">
<input type = "radio" id = "option2" name = "gender"
class = "mdl-radio__button" >
<span class = "mdl-radio__label">Female</span>
</label>
</td>
<td>
<label class = "mdl-radio mdl-js-radio" for = "option3">
<input type = "radio" id = "option3" name = "gender"
class = "mdl-radio__button" disabled>
<span class = "mdl-radio__label">Don't know (Disabled)</span>
</label>
</td>
</tr>
</table>
</body>
</html>
結果
驗證結果。
廣告