- 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
广告