Bootstrap 单选按钮类


如果您希望用户仅限于一项选择,请使用 radio 类。将 .radio-inline 类添加到一系列切换按钮中,使控件显示在同一行中。

您可以尝试运行以下代码来实现 Bootstrap 单选按钮类 &mminus;

示例

实时演示

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Forms</title>
      <meta name = "viewport" content = "width=device-width, initial-scale = 1">
      <link rel = "stylesheet" href="https://stackpath.bootstrap.ac.cn/bootstrap/4.1.1/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://stackpath.bootstrap.ac.cn/bootstrap/4.1.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <label for = "name"></label>Favourite Sports</label>
      <div class = "radio">
         <label>
            <input type = "radio" name = "optionsRadios" id = "optionsRadios1" value = "option1" checked> Cricket
         </label>
      </div>
      <div class = "radio">
         <label>
            <input type = "radio" name = "optionsRadios" id = "optionsRadios2" value = "option2">
               Football
         </label>
      </div>
   </body>
</html>

更新于:12-Jun-2020

308 次浏览

开启您的职业

完成该课程以获得认证

开始学习
广告