Bulma教程

Bulma 复选框和单选框

说明

当您希望用户从预设选项列表中进行选择时,可以使用复选框(从给定列表中选择多个选项)和单选按钮(从给定列表中仅选择一个选项)。在输入标签中使用 checkboxradio 类来保持跨浏览器兼容性和用户体验。

复选框

下面的例子展示了在 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>
它显示以下输出-
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4