我希望将表格保留在div
标记内,但遗漏了最后一部分的一半。
这是我用过的html结构,
.dataTable{
table-layout: fixed;
}
.dataTable td{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="row">
<div class="col-md-12">
<table class="dataTable">
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
</div>
</div>
</body>
</html>
任何人都可以帮我解决这个问题吗?
答案 0 :(得分:1)
试试这个:
.dataTable{
table-layout: fixed;
width: 100%;
}
希望这可以帮助你...
答案 1 :(得分:0)
试试这个:
$(document).ready(function () {
$('#YourTable').DataTable({
"scrollX": true,
});
});