html - 如何使表格以固定标题( Bootstrap )滚动?

标签 html css twitter-bootstrap

这是代码。我试过 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/

相关文章:

javascript - 在html文本中随机更改大写/小写

javascript - Bootstrap 轮播在 Firefox 中不起作用

php - 在 laravel 中使用 bootstrap-datepicker

html - 如何阻止 div 换行?

javascript - 外部 css 是否应用于 jsPDF 生成的 pdf

html - 覆盖父标签中的 CSS 继承

css - 是否有用于文本节点的 CSS 选择器?

html - 如何在我的案例中设置元素的绝对位置?

javascript - 如何在向下滚动条的jquery中用slideUp打开一个div

javascript - Bootstrap 3 弹出框不工作