【发布时间】:2017-08-14 11:36:18
【问题描述】:
我想将表格保留在 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>
谁能帮我解决这个问题?
【问题讨论】:
-
尝试删除
overflow: hidden; -
尝试移除溢出:隐藏;以为它会在底部添加一个滚动条,如果您不希望这样,请减小其中一列的宽度
-
尝试为此提供jsfiddle链接。
-
当我删除
overflow: hidden;' it goes over othertd`s -
您在问题中拥有的数据与图像中使用的数据量不同。 3 cols 而不是 5 cols。你能解决这个问题吗?这就是我得到的jsfiddle.net/gkktq81t/1
标签: html css twitter-bootstrap datatable