简体   繁体   English

如何将@html.editorfor 居中?

[英]How to put @html.editorfor to center?

Im gonna make an edit page that updates bikes.我要制作一个更新自行车的编辑页面。 Ive been using bootstrap for html design, but looks like it doesnt work correctly anymore.我一直在为 html 设计使用引导程序,但看起来它不再正常工作了。 Here's my codes;这是我的代码;

 @model Avent.Entity.Bike

@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Edit Bike @Model.Brand @Model.BikeModel</h2>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    
<div class="form-horizontal col-12 text-center">
    <h4>Bike</h4>
    <hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    @Html.HiddenFor(model => model.Id)
    <img class="img-thumbnail" src="@Model.Image" />
    <div class="form-group text-center">
        @Html.LabelFor(model => model.CreationDate, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-6 text-center">
            @Html.EditorFor(model => model.CreationDate, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.CreationDate, "", new { @class = "text-danger" })
        </div>
    </div>

I tried whatever i can do but labels put center and textboxes not.我尝试了我能做的任何事情,但标签放在中心而不是文本框。 :( Can you please help me? :( 你能帮我么?

You can use '.justify-content-center' or '.offset-md-3' classes from the Grid System of Bootstrap .您可以使用Bootstrap网格系统中的 '.justify-content-center' 或 '.offset-md-3' 类。

Here is a sample code.这是一个示例代码。 https://www.codeply.com/p/CH1zSO7u6j https://www.codeply.com/p/CH1zSO7u6j

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

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