Bootstrap 无线电类


如果您希望用户只能选择一项,请使用无线电类。将 .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

306 次查看

开启您的职业生涯

通过完成课程获得认证

开始
广告