html - 动态生成的 HTML 表格 - 如何限制宽度

标签 html css html-table

我正在使用 MVC3 创建一个动态表。

但是表格在布局中离开了页面并且没有驻留在共享 div 中?

@{
    ViewBag.Title = "Users";
}

<h2>Users</h2>

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


    <table>
        <tr>
            <th>
                UserID
            </th>
            <th>
                UserName
            </th>
            <th>
                UserForename
            </th>
            <th>
                PW
            </th>
            <th>
                UserTypeID
            </th>
            <th>
                PasswordMustBeChanged
            </th>
             <th></th>
        </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
              @Html.DisplayFor(modelItem => item.U1_UserId)
            </td>
            <td>
                 @Html.DisplayFor(modelItem => item.U1_UserName)
            </td>
             <td>
               @Html.DisplayFor(modelItem => item.U1_UserForename)
            </td>
             <td>
               @Html.DisplayFor(modelItem => item.U1_PW)
            </td>
            <td>
                 @Html.DisplayFor(modelItem => item.U1_UserTypeID)
            </td>
             <td>
               @Html.DisplayFor(modelItem => item.U1_PasswordMustBeChanged)
            </td>
             <td>
                @Html.ActionLink("Edit", "Edit", new { id=item.U1_UserId }) |
                @Html.ActionLink("Delete", "Delete", new { id=item.U1_UserId })
            </td>       
        </tr>
    }

这是表格,它在共享 layotu @renderbody 中呈现。但是表格并没有留在 div 中..?

最佳答案

只是在黑暗中拍摄,但您似乎有一个额外的 <th></th>在你的标题部分?是故意的吗?

关于html - 动态生成的 HTML 表格 - 如何限制宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6813778/

相关文章:

javascript - 使用JQuery动态添加表格行设置小行高

html - 格式化链接,使它们出现在 CSS 图像的顶部

html - Section 标签不包含标题可以吗?

css - 在 Bootstrap 中出现全屏按钮

android - 如何给安卓应用添加样式

html - 溢出表TD宽度相对宽度

php - 如何在 PHP 中的表格中显示搜索结果

javascript - 如何从谷歌搜索结果 "20-pack"条目中提取源?

行的 python pandas 着色

表格样式中的 HTML/CSS 表格