如何在强类型视图中将标签和文本框放在一行中

how to bring label and text box in one line in strongly typed view

我的标签出现在上面,下面显示输入框,我希望两者在同一行。

 <fieldset>
    <legend style="color:red">Enter Details</legend><br />

    <div style="color:red">
        @Html.LabelFor(model => model.Name)
    </div>
    <div class="editor-field" style="color:InfoBackground">
        @Html.EditorFor(model => model.Name)
        @Html.ValidationMessageFor(model => model.Name)
    </div><br/>

    <div class="editor-field" style="color:red">
        @Html.LabelFor(model => model.Country)
    </div>
    <div class="editor-field" style="color: InfoBackground">
        @Html.EditorFor(model => model.Country)
        @Html.ValidationMessageFor(model => model.Country)
    </div><br/>

    <div class="editor-label" style="color:red">
        @Html.LabelFor(model => model.Mobile_Number)
    </div>
    <div class="editor-field" style="color: InfoBackground">
        @Html.EditorFor(model => model.Mobile_Number)
        @Html.ValidationMessageFor(model => model.Mobile_Number)
    </div><br/>

    <div align="center"><input type=submit" value="submit" /></div>
</fieldset>

一定要改什么done.Please求助!!!

您的标签包裹在 div 中。 Div 是 default display:block. 这意味着他们强制换行。

最简单的做法是将您的@Html.LabelFor 和@Html.EditorFor 放在同一个 div 中,然后更改您的 css 以获得您想要的效果。

如您所知,Div 默认为 display:block。因此,如果您想向内显示标签或输入等,请更新 div 样式。应用按照您要显示的 div 样式。

style="display:inline-block;"