gpt4 book ai didi

css - 当记录结果超出时,如何修复 Bootstrap 表大小调整

转载 作者:行者123 更新时间:2023-11-28 03:44:03 26 4
gpt4 key购买 nike

我有一个由模型的 MVC 循环填充的 Bootstrap 表。但是,当我的模型呈现大量记录时,它会导致嵌套在表格中的表格和面板的高度过高。当返回的记录超过表的最大高度属性时,是否有推荐的方法使表结果可滚动?可滚动的解决方案将是最佳的。

样式

.table{
width:100%;
}
thead,tbody,tr,td,th{
display:grid;

}
tr:after{
content: ' ';
display: block;
visibility:hidden;
clear:both;
}
thead th{
height: 30px;
}
tbody {
height: 120px;
overflow-y:auto;
}
thead {

}

tbody td. thead th {
width: 40.2%;
float: left;
}

代码如下:(循环显示34条记录)

<div class="panel panel-primary">
<div class="panel-heading clearfix">
<h4 class="panel-title pull-left" style="padding-top: 7.5px;">My Team</h4>
<div class="btn-group pull-right">
<!--- Search bar-->
<form class="navbar-form navbar-right" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search My Team">
<span class="input-group-btn">
<button type="submit" class="btn btn-default">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
</div>
</form>
</div>
</div>
<table class="table table-responsive table-hover" style="max-height:150px; height:100px;">
<thead>
<tr>
<th>@Html.DisplayNameFor(model => model.Name)</th>
<th>LAN ID</th>
<th>Department</th>
<th>Email</th>
</tr>
</thead>
<tbody>
@foreach(var x in Model)
{
<tr class="info">
<td>
@Html.DisplayFor(modelItem => x.Name)
</td>
<td>
@Html.DisplayFor(modelItem => x.Lan_Id)
</td>
<td>
@Html.DisplayFor(modelItem => x.CurrDept)
</td>
<td>
@Html.DisplayFor(modelItem => x.Email)
</td>
</tr>
}
</tbody>
</table>
<div class="panel-footer"></div>

最佳答案

制作表结构如下。应该可以解决您的问题

<div class="table-responsive">
<table class="table table-striped table-bordered">
//rest of code
</table>
</div>

关于css - 当记录结果超出时,如何修复 Bootstrap 表大小调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44078468/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com