【发布时间】:2020-08-09 11:38:36
【问题描述】:
我的 MVC 视图中有两个数据表。我可以将它们并排显示。但是当我调整浏览器的大小(还原)时,数据表相互重叠,而不是一个在另一个之下。当浏览器为全尺寸时,如何使数据表彼此相邻,而当我调整浏览器大小时,如何使数据表在另一个下方?我在 MVC razor 视图中使用 Bootstrap 4。
注意:这是我第一次在 stackoverflow 中附加 sn-p。所以如果不正确请多多包涵!
Tables aligned next to each other when on full screen
tables squeezing next to each other when resized
.dataTables_wrapper {
border: thin solid #808080;
border-collapse: collapse;
padding-top: 1rem;
padding-right: 2rem;
padding-left: 2rem;
padding-bottom: 1rem;
}
<div>
@if (Enumerable.Count(ViewBag.recentprojects) > 0) {
<div class="col-xs-6">
<div class="table-responsive">
<table id="data" class="table table-bordered table-striped table-responsive">
<thead style="background-color:lightgray">
<tr>
<th class="text-center" style="cursor:pointer;background-color:burlywood">
@Html.DisplayName("My Recent Projects")
</th>
</tr>
<tr>
<th class="text-center" style="cursor:pointer">
@Html.DisplayName("Projects")
</th>
</tr>
</thead>
<tbody id="projects">
@foreach (var item in ViewBag.recentprojects) {
<tr>
<td class="col">
<a href="#"> @item.ProjectCode</a>: @item.ProjectTitle
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
<div class="col-xs-1">
</div>
<div class="col-xs-1">
</div>
<div class="col-xs-1">
</div>
<div class="col-xs-1">
</div>
@if ((ViewBag.Leader is true) && (Enumerable.Count(ViewBag.teamprojects) > 0)) {
<div class="col-xs-6">
<div class="table-responsive">
<table id="data1" class="table table-bordered table-striped table-responsive">
<thead style="background-color:lightgray">
<tr>
<th class="text-center" style="cursor:pointer;background-color:burlywood">
@Html.DisplayName("My Team's Recent Projects")
</th>
</tr>
<tr>
<th class="text-center" style="cursor:pointer">
@Html.DisplayName("Projects")
</th>
</tr>
</thead>
<tbody id="projects">
@foreach (var item in ViewBag.teamprojects) {
<tr>
<td class="col">
<a href="#"> @item.ProjectCode</a>: @item.ProjectTitle
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
</div>
【问题讨论】: