- Bulma 教程
- Bulma - 主頁
- Bulma - 簡介
- Bulma - 概述
- Bulma - 修飾符
- Bulma - 列
- Bulma - 佈局
- Bulma - 表單
- Bulma - 元素
- Bulma - 元件
- Bulma 實用資源
- Bulma - 快速指南
- Bulma - 資源
- Bulma - 討論
Bulma - 複選框和單選按鈕
說明
當您希望使用者從給定列表中選擇時,可以使用複選框(從給定列表中選擇多項選項)和單選按鈕(僅從給定列表中選擇一項選項)。在輸入標籤中使用 checkbox 和 radio 類以保持跨瀏覽器的相容性和使用者體驗。
複選框
以下示例展示瞭如何在 Bulma 中使用 checkbox 類建立複選框 -
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<title>Bulma Forms Example</title>
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
<script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
</head>
<body>
<section class = "section">
<div class = "container">
<span class = "title">
Checkbox
</span>
<br>
<br>
<div class = "checkbox">
<label class = "is-size-5">Fruits</label>
<br>
<label class = "checkbox">
<input type = "checkbox">
Orange
</label>
<label class = "checkbox">
<input type = "checkbox">
Apple
</label>
<label class = "checkbox">
<input type = "checkbox">
Grapes
</label>
<label class = "checkbox">
<input type = "checkbox">
Mango
</label>
</div>
<br>
<br>
<label class = "is-size-5">Disabled Checkbox</label>
<br>
<label class = "checkbox" disabled>
<input type = "checkbox" disabled>
Orange
</label>
</div>
</section>
</body>
</html>
它顯示以下輸出 -
單選按鈕
以下示例展示瞭如何在 Bulma 中建立單選按鈕(在標籤中使用 radio 類)-
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<title>Bulma Forms Example</title>
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
<script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
</head>
<body>
<section class = "section">
<div class = "container">
<span class = "title">
Radio Button
</span>
<br>
<br>
<div class = "checkbox">
<label class = "is-size-5">Fruits</label>
<br>
<label class = "radio">
<input type = "radio" name = "fruitdemo">
Orange
</label>
<label class = "radio">
<input type = "radio" name = "fruitdemo">
Apple
</label>
</div>
<br>
<br>
<label class = "is-size-5">Disabled Radio Button</label>
<br>
<label class = "radio">
<input type = "radio" name = "fruitdemo">
Orange
</label>
<label class = "radio" disabled>
<input type = "radio" name = "fruitdemo" disabled>
Apple
</label>
<br>
<br>
<label class = "is-size-5">Using checked HTML attribute</label>
<br>
<label class = "radio">
<input type = "radio" name = "fruitdemo" checked>
Orange
</label>
<label class = "radio">
<input type = "radio" name = "fruitdemo">
Apple
</label>
</div>
</section>
</body>
</html>
它顯示以下輸出 -
bulma_form.htm
廣告