0

我正在努力制作新行,我有复选框,每个都必须有自己的新行。知道如何在表单组行中使用引导类来实现这一点吗?

<div class="form-group row">
    <label for="Dietary requirement" class="col-sm-2 col-form-label">Dietary requirements</label>
    <div class="col-sm-2">
        @Html.CheckBoxFor(model => model.DietMain.None)<label for="None">None</label>
        <hr />
    </div>
                                
    <div class="form-group row">
        &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        @Html.CheckBoxFor(model => model.DietMain.Vegetarian)<label for="Vegetarian">Vegetarian</label>
    </div>
</div>
4

1 回答 1

0

更改col-sm-2col-sm-12并删除所有&nbsp;,然后将new { @class="col-md-12" } htmlAttributes添加到@Html.CheckBoxFor(model => model.DietMain.Vegetarian)

<div class="form-group row">
    <label for="Dietary requirement" class="col-sm-12 col-form-label">Dietary requirements</label>
    <div class="col-sm-12">
        @Html.CheckBoxFor(model => model.DietMain.None)<label for="None">None</label>
        <hr />
    </div>
                            
    <div class="form-group row">
        @Html.CheckBoxFor(model => model.DietMain.Vegetarian, new { @class="col-md-12" }) 
        <label for="Vegetarian">Vegetarian</label>
    </div>
</div>
于 2020-06-24T12:37:19.573 回答