简体   繁体   English

如何获得与引导程序内联的标签和单选按钮?

[英]How do I get a label and radio buttons inline with bootstrap?

I know this should be simple, but the solution eludes me. 我知道这应该很简单,但解决方案让我望而却步。 My test-site illustrates my frustration. 我的测试网站说明了我的沮丧。

<div class="form-group row">
    <label for="choose-type" class="col-sm-2 form-control-label label-inline">Account Type</label>
    <div id="choose-type" class="col-sm-10 div-inline">
        <label class="radio-inline">
            <input type="radio" class="radio-inline" name="user-type" id="writer" value="1" required > Writer
        </label>
        <label class="radio-inline">
            <input type="radio" class="radio-inline" name="user-type" id="enabler" value="2" required> Enabler
        </label>
    </div>
</div>

Please try this. 请试试这个。 You have padding in the divs which is throwing your bootstrap layout off (col-sm-10 and col-sm-2 don't have enough space). 你在div中填充了你的引导布局(col-sm-10和col-sm-2没有足够的空间)。 I have changed col-sm-10 to col-sm-8 to accommodate. 我已将col-sm-10更改为col-sm-8以适应。

<div class="form-group row">
    <label for="choose-type" class="col-sm-2 form-control-label label-inline">Account Type</label>
    <div id="choose-type" class="col-sm-8 div-inline">
        <label class="radio-inline">
            <input type="radio" class="radio-inline" name="user-type" id="writer" value="1" required=""> Writer
        </label>
        <label class="radio-inline">
            <input type="radio" class="radio-inline" name="user-type" id="enabler" value="2" required=""> Enabler
        </label>
    </div>
</div>

I'm guessing you're talking about the height difference between the text and the radio-button. 我猜你在谈论文本和单选按钮之间的高度差异。 Remove the second radio-inline from the <input> elements, the radio-inline from the <label> is sufficient. <input>元素中删除第二个radio-inline radio-inline<label>radio-inline就足够了。

<div class="form-group row">
    <label for="choose-type" class="col-sm-2 form-control-label label-inline">Account Type</label>
    <div id="choose-type" class="col-sm-10 div-inline">
        <label class="radio-inline">
            <input type="radio" class="" name="user-type" id="writer" value="1" required > Writer
        </label>
        <label class="radio-inline">
            <input type="radio" class="" name="user-type" id="enabler" value="2" required> Enabler
        </label>
    </div>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM