如何在asp.net文本框中左右两侧添加标签

时间:2017-06-08 12:23:31

标签: c# asp.net-mvc twitter-bootstrap

我尝试在文本框的右侧添加标签以包含值的单位。I would like to have like this

This code gives like this

这是我的代码

    <div class="form-group ">

                    @Html.LabelFor(model => model.files, htmlAttributes: new { @class = "control-label col-md-3" })
                    <div class="col-md-8">
                        @{ Html.EnableClientValidation(false); }

                        @Html.EditorFor(model => model.files, new { htmlAttributes = new { @class = "form-control " } })<span>GB</span>
                        @{ Html.EnableClientValidation(true); }
                        @Html.ValidationMessageFor(model => model.files, "", new { @class = "text-danger" })

                    </div>
                </div>

感谢。

1 个答案:

答案 0 :(得分:1)

class =“col-md-8”包含position:relative。 由于此行具有class =“form control”,并且您的GB没有类。它走向了自然的位置。添加一个类应该告诉它去哪里。

@Html.EditorFor(model => model.files, new { htmlAttributes = new { @class = "form-control col-md-11" } })<span class="col-md-1">GB</span>