css - Datatables lost sidebar
问题描述
I'm using Datatables
and Bootstrap
, and I'm trying to add a sidebar on the left side of the datatables
, actually I did half of the job, infact I created this code:
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" crossorigin="anonymous">
</head>
<div class="row">
<div class="col-12">
<div class="card">
<a data-toggle="collapse" href="#fixtures" role="button"
class="btn btn-rounded hide-btn btn-sm ml-1" aria-expanded="false" aria-controls="fixtures">
<i class="mdi mdi-view-agenda"></i>
</a>
<div class="card-body collapse show rounded-full-margin" id="fixtures">
<div class="container-fluid">
<div class="row">
<div class="col-3 px-1 bg-dark" id="sticky-sidebar">
<div class="py-2 sticky-top">
<div class="nav flex-column">
<a href="" class="nav-link">Sidebar</a>
<a href="" class="nav-link">Link</a>
<a href="" class="nav-link">Link</a>
<a href="" class="nav-link">Link</a>
<a href="" class="nav-link">Link</a>
<a href="" class="nav-link">Link</a>
</div>
</div>
</div>
<div class="col" id="main">
<h4 class="header-title text-center">Matches</h4>
<table id="fixtures-datatable" class="table dt-responsive nowrap">
<thead>
<tr>
<th class="sorting">League</th>
<th class="sorting">Hour</th>
<th class="sorting text-center">Home</th>
<th class="sorting text-center">Result</th>
<th class="sorting text-center">Away</th>
</tr>
</thead>
<tbody>
<tr>
<td>BR,Brazil: Serie B</td>
<td>00:15</td>
<td class="text-right">
Guarani
<img src="https://secure.cache.images.core.optasports.com/soccer/teams/150x150/316.png" height="20" />
</td>
<td class="text-center">0 - 2</td>
<td class="text-left">
<img src="https://secure.cache.images.core.optasports.com/soccer/teams/150x150/307.png" height="20" />
Goiás
</td>
</tr>
<tr>
<td>BR,Brazil: Serie B</td>
<td>01:30</td>
<td class="text-right">
São Bento
<img src="https://secure.cache.images.core.optasports.com/soccer/teams/150x150/6120.png" height="20" />
</td>
<td class="text-center">1 - 0</td>
<td class="text-left">
<img src="https://secure.cache.images.core.optasports.com/soccer/teams/150x150/322.png" height="20" />
Paysandu
</td>
</tr>
<tr>
<td>BR,Brazil: Serie B</td>
<td>01:30</td>
<td class="text-right">
Juventude
<img src="https://secure.cache.images.core.optasports.com/soccer/teams/150x150/314.png" height="20" />
</td>
<td class="text-center">0 - 1</td>
<td class="text-left">
<img src="https://secure.cache.images.core.optasports.com/soccer/teams/150x150/305.png" height="20" />
Criciúma
</td>
</tr>
<tr>
<td>BR,Brazil: Serie B</td>
<td>00:15</td>
<td class="text-right">
Avaí
<img src="https://secure.cache.images.core.optasports.com/soccer/teams/150x150/330.png" height="20" />
</td>
<td class="text-center">1 - 0</td>
<td class="text-left">
<img src="https://secure.cache.images.core.optasports.com/soccer/teams/150x150/344.png" height="20" />
CRB
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- End card-body -->
</div>
</div>
</div>
if you execute the code in this JSFIDDLE you will get the following result:
Now if you reduce the window dimension you will see this issue:
as you can see the datatables
falls on another row, but I need to keep both sidebar + datatables on the same line (even when I reduce the window resolution). How can I do that? Perhaps with the overlaps?
解决方案
在引导程序中,一行中有 12 列。在您的情况下,如果您的侧边栏跨越一行的 3 列,那么您必须将其余列分配给您的数据表。
将您<div class="col" id="main">
的更改<div class="col-9" id="main">
为满足原始的总共 12 列。类前缀类似于.col-
或.col-sm
- 或.col-md-
.col- means extra-small
.col-sm- means small
.col-md- means medium
.col-lg- means large
.col-xl- means extra
最大容器宽度:
.col- = None (auto)
.col-sm- = 540px
.col-md- = 720px
.col-lg- = 960px
.col-xl- = 1140px
还要检查每个特定原始数据所花费的列数并进行相应计算。
谢谢
推荐阅读
- amazon-ec2 - 在 ec2 完成在其上运行的进程之前停止 ec2 以缩小规模
- algorithm - 背包问题 - 从 5 组中选择最佳可能的项目组合,包括每组 1 项
- spotfire - 在spotfire中链接两个表
- google-cloud-platform - 谷歌云平台服务帐号无法访问项目
- javascript - JS 分数数组:如何在分数数组中添加一个数字并剔除较小的数字?
- arrays - 在 Google 表格中创建一列中的所有值与另一列中的所有值的组合列表
- neo4j - 密码查询:相关节点不同
- javascript - 从数据库加载数据后如何使动态表单自行刷新
- c++ - 在命令提示符下在我的 g++ (5.1.0) 编译器上使用 unordered_map 显示错误
- javascript - 如何为 ASP.NET Menu 和 MenuItem 控件包含 onfocus 和 onblur 事件