首页 > 解决方案 > 如何在表单中创建单选按钮组以允许选择餐厅的吸烟/非吸烟部分?

问题描述

我希望使用引导程序来模拟单选按钮的行为,form-group因此表单中的一行有几个按钮(例如“btn btn-success”),这些按钮可以“选择”,但只有一个可以是在给定的时刻选择。我想要这样的输出:

但我得到了这个:

在此处输入图像描述

我也无法选择吸烟按钮

以下代码是:

 <div class="form-group row">
    <label for="section" class="col-12 col-md-2">Section</label>
       <div class="col-md-10">
         <div class="btn-group" data-toggle="buttons">
            <label class="btn btn-success active">
              <input type="radio" name="options" id="option1" autocomplete="off" checked>Non- 
               Smoking
            </label>
          <label class="btn btn-danger">
             <input type="radio" name="options" id="option2" autocomplete="off">Smoking
          </label>
        </div>
     </div>
 </div>

标签: javascripthtmlcssbootstrap-4bootstrap-modal

解决方案


试试这个

input[type="radio"] {
    visibility:hidden;
}

推荐阅读