如何居中对齐面板的内容

时间:2015-10-02 18:56:59

标签: asp.net-mvc html5 css3 razor

我想集中放置内容(dom元素),即标签和下拉菜单。请帮助我。这是我在cshtml中的代码。 我想将Region下拉列表和Region下拉列表中心对齐。

@model IEnumerable<HuRIS.Models.Zone>

@{
ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>

<div class="panel panel-info">
    <div class="panel-body">
        <div class="form-group">
            <div class="col-md-2"></div>
            <label for="RegionID" class="col-md-1">Region:</label>
            @Html.DropDownList("RegionID", null, htmlAttributes: new { @class = "form-control col-md-7" })
            <div class="col-md-2"></div>
        </div>
    </div>
</div>


<table class="table">

    <tr>
        <th>
            @Html.DisplayNameFor(model => model.devregion.RegionName)

        </th>
        <th>
            @Html.DisplayNameFor(model => model.ZoneCode)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ZoneName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.isActive)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.devregion.RegionName)

            </td>
            <td>
                @Html.DisplayFor(modelItem => item.ZoneCode)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.ZoneName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.isActive)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.ZoneID }) |
                @Html.ActionLink("Details", "Details", new { id = item.ZoneID }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.ZoneID })
            </td>
        </tr>
    }

</table>

1 个答案:

答案 0 :(得分:0)

试试这个(假设Bootstrap 3):

    <div class="form-group center-block">
        <label for="RegionID" class="control-label">Region:</label>
        @Html.DropDownList("RegionID", null, htmlAttributes: new { @class = "form-control" })
    </div>

类似小提琴http://jsfiddle.net/tzhben/bpqmx8vd/