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.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://stackpath.bootstrapcdn.com/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 次瀏覽

開啟您的職業

完成該課程以獲得認證

開始學習
廣告
© . All rights reserved.