asp.net-mvc - 如何使用内联 css 修复引导表的标题?
问题描述
我正在尝试使用引导模板创建一个带有固定标题的可排序表。bootstrap 的 css 文件很复杂,所以我正在寻找一种方法来通过使用内联 css 来修复表格的标题。
这是我到目前为止得到的:
<div class="row" style="margin-top: 3%;">
<div class="col-lg-12 d-flex align-items-stretch" style="height: 650px; overflow: auto;">
<table id="dtDynamicVerticalScrollExample" class="table table-striped table-bordered table-sm" cellspacing="0" width="100%">
<tr>
<th>
ID
</th>
<th>
Company
</th>
<th>
Name
</th>
<th>
URL
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.ApiRedirectID)
</td>
<td>
@Html.DisplayFor(modelItem => item.Company.CompanyName)
</td>
<td>
@Html.DisplayFor(modelItem => item.ApiName)
</td>
<td>
@Html.DisplayFor(modelItem => item.ApiURL2)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ApiRedirectID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ApiRedirectID })
</td>
</tr>
}
</table>
</div>
</div>
我尝试过将 position 属性与内联 css 一起使用,如下所示:
<tr style="position:fixed">
这将导致以下结果:
希望有人知道解决方案。
提前致谢!
解决方案
thead, tbody, tr, td, th { display: block; }
推荐阅读
- plot - jQuery Flot - 放大/缩小时在 X 和 Y 上强制相同的刻度间隔
- compiler-construction - 漂亮的打印模棱两可的语法
- google-photos - 使用 API 将照片整理到相册中
- wcf - WCF 服务主机找不到任何服务元数据。请检查元数据是否启用
- spring-boot - 无法在 Spring Boot 中停止并发会话(Keycloak 身份验证服务器)
- parsing - LR(1) 使用 epsilon 产生式解析表
- c# - 字符串 Text.ToUpper() 在 C# Visual Studio 2017 版本 15.1.1 中的 Linq 查询中运行缓慢
- php - PHP:2个存储过程称为-“表名已经存在”
- angular - 如何以角度 4 从 asp.net web api 加载图像?
- r - 在 R 中的同一图中绘制两个条形图