| 复选框用于让用户从一系列预设置的选项中进行选择,可以选一个或多个。 
 以下实例包含了三个选项。最后一个是禁用的:
 
 实例:
 
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bootstrap4 实例</title>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank" >
 <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
 <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
 <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
 </head>
 <body>
 <div class="container">
 <h2>表单控件: checkbox</h2>
 <p>以下实例包含了三个选项。最后一个是禁用的:</p>
 <form>
 <div class="form-check">
 <label class="form-check-label">
 <input type="checkbox" class="form-check-input" value="">Option 1
 </label>
 </div>
 <div class="form-check">
 <label class="form-check-label">
 <input type="checkbox" class="form-check-input" value="">Option 2
 </label>
 </div>
 <div class="form-check disabled">
 <label class="form-check-label">
 <input type="checkbox" class="form-check-input" value="" disabled>Option 3
 </label>
 </div>
 </form>
 </div>
 </body>
 </html>
 尝试一下
 使用 .form-check-inline 类可以让选项显示在同一行上:
 
 实例:
 
 <!DOCTYPE html>
 <html>
 <head>
 <title>Bootstrap4 实例</title>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank" >
 <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
 <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
 <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
 </head>
 <body>
 <div class="container">
 <h2>表单控件: checkbox</h2>
 <p>以下实例包含了三个选项。最后一个是禁用的,使用 .form-check-inline 类可以让选项显示在同一行上:</p>
 <form>
 <div class="form-check form-check-inline">
 <label class="form-check-label">
 <input type="checkbox" class="form-check-input" value="">Option 1
 </label>
 </div>
 <div class="form-check form-check-inline">
 <label class="form-check-label">
 <input type="checkbox" class="form-check-input" value="">Option 2
 </label>
 </div>
 <div class="form-check form-check-inline disabled">
 <label class="form-check-label">
 <input type="checkbox" class="form-check-input" value="" disabled>Option 3
 </label>
 </div>
 </form>
 </div>
 </body>
 </html>
 尝试一下
 |