这是代码。我试过 overflow:scroll
,我很确定,这就是我要找的那段代码,但同样的错误发生了。有人能帮我吗?
这是一个简单的 Bootstrap 表。不幸的是,我尝试过的解决方案都没有奏效。
.stavre
{
table-layout: fixed;
height: 200px;
}
.stavre table {
padding: 5px;
border: 1px solid #eee;
width: 100px;
word-wrap: break-word;
overflow: scroll;
}
.stavre table {
height: 200px;
}
</style>
</head>
<body>
<div class= "container">
<div class="stavre">
<table class="table-responsive table table-bordered">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary@example.com</td>
</tr>
<tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july@example.com</td>
</tr>
<tr>
<td>Tomi</td>
<td>Nane</td>
<td>Tomi@example.com</td>
</tr>
<tr>
<td>Miro</td>
<td>Jovanovski</td>
<td>Miro@example.com</td>
</tr>
<tr>
<td>Dragi</td>
<td>Kostovski</td>
<td>Dragi@example.com</td>
</tr>
</tr>
</table>
</div>
<div>
</body>
</head>
</html>
最佳答案
您可以尝试将 max-height 放在 stavre 类上,这样当它超过指定的高度时,它会自动显示滚动条。
关于html - 如何使表格以固定标题( Bootstrap )滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34767137/