如何解决分页引导程序DataTables包含很多空间
我正在尝试获得与数据表引导演示相同的结果:
https://datatables.net/media/blog/bootstrap/
我下面的引导分页有很多空格,并且不知道为什么以及如何解决此问题。 我想像演示一样适合分页结果。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
<table class="table table-striped table-bordered" style="width:100%" id="example">
<thead>
<tr>
<td>ID</td>
<td>Code</td>
<td>Name</td>
<td>City</td>
</tr>
</thead>
<tbody>
<?php
$conn = new mysqli('localhost','login','password','dbname');
$sql = $conn->query('SELECT * FROM countries');
while ($data = $sql->fetch_array()) {
echo '<tr>
<td>' . $data['id'] . '</td>
<td>' . $data['country_code'] . '</td>
<td>' . $data['country_name'] . '</td>
<td>' . $data['city'] . '</td>
</tr>
';
}
?>
</tbody>
</table>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.22/js/dataTables.bootstrap4.min.js"></script>
<script>
$(document).ready(function() {
$('#example').dataTable()
});
</script>
</body>
</html>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。