css - asp.net mvc 如何让表头居中对齐?

标签 css asp.net-mvc twitter-bootstrap twitter-bootstrap-3

这是我在 asp.net mvc 中的表的代码。

<div class="span4 proj-div text-center" data-toggle="modal" data-target="#addLanguageModal">
<u>Add Language</u>
<table class="table table-bordered table-dark-header table-responsive">
    <tr class="text-center">
        <th>Language Name</th>
        <th>Welcome Message</th>
        <th></th>
    </tr>


    @foreach (var item in Model.Languages)
    {
        <tr>
            <td>@Html.DisplayFor(modelItem => item.LanguageName)</td>
            <td>@Html.DisplayFor(modelItem => item.Message)</td>
            <td>
                @Html.ActionLink("Edit", "EditLanguage", "Country", new { id = item.LanguageId })|
                @Html.ActionLink("Delete", "DeleteLanguage", "Country", new { id = item.LanguageId })
            </td>
        </tr>
    }
</table>

屏幕喜欢: image

您会看到标题在左侧。我希望标题文本位于中心。 我们可以使用 Bootstrap 类来做到这一点吗?

最佳答案

向每个 th 添加类名 class="text-center"

或者在你的 CSS 中:

th {
  text-align: center;
}

Bootstrap documentation - alignment classes

关于css - asp.net mvc 如何让表头居中对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44737086/

相关文章:

html - 使用 inline-block 和 float left 垂直和水平堆叠内容

html - 如何使用 Material ui在reactjs/css中创建一个包含tableHead单元格的表格

c# - Request.IsAuthenticated 返回 false 除非页面刷新

jquery - 从 JSON 类型的操作返回时出现奇怪的日期时间格式

css - Bootstrap : list-inline with bullets?

html - 仅当有超过 2 个 child 时显示

jquery - 按播放/暂停按钮停止和开始 gif

asp.net-mvc - MVC 验证接受 ddMMyyyy 格式的日期时间

css - 强制 Bootstrap 响应图像为正方形

javascript - Bootstrap 列达到相同的高度,子级与高度匹配