W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h2>复选框</h2> <p>如需设置复选框的样式,请使用带有 .form-check 类的容器元素,并将 .form-check-label 添加到标签,并将 .form-check-input 添加到 type="checkbox" 的输入控件中。</p> <p>下面的表格包含三个复选框。默认选中第一个选项,禁用最后一个选项:</p> <form action="/demo/html/action_page.php"> <div class="form-check"> <input type="checkbox" class="form-check-input" id="check1" name="option1" value="something" checked> <label class="form-check-label" for="check1">选项 1</label> </div> <div class="form-check"> <input type="checkbox" class="form-check-input" id="check2" name="option2" value="something"> <label class="form-check-label" for="check2">选项 2</label> </div> <div class="form-check"> <input type="checkbox" class="form-check-input" disabled> <label class="form-check-label">选项 3</label> </div> <button type="submit" class="btn btn-primary mt-3">提交</button> </form> </div> </body> </html>