简体   繁体   English

如何在页面滚动时使 bootstrap 4 表 header 粘在顶部

[英]how to make bootstrap 4 table header sticky on top when page scroll

I'm using argon dashboard by creative tim https://demos.creative-tim.com/argon-dashboard/ .我正在使用 creative tim https://demos.creative-tim.com/argon-dashboard/的 argon 仪表板。 Now I want table header remains at the top when scrolling page.现在我希望表 header 在滚动页面时保持在顶部。 I tried using class sticky-top but it does not work.我尝试使用 class sticky-top 但它不起作用。

                           <thead class="thead-light sticky-top">
                            <tr>
                                <th scope="col-2" class="sort" data-sort="name">Customer ID</th>
                                <th scope="col" class="sort" data-sort="budget">Company</th>
                                <th scope="col" class="sort" data-sort="status">Employees</th>
                                <th scope="col">Country</th>
                                <th scope="col" class="sort" data-sort="completion">Last admin login</th>
                                <th scope="col">Last employee login</th>
                                <th scope="col">Last invoice</th>
                                <th scope="col">Next invoice</th>
                                <th scope="col">Total invoiced</th>
                                <th scope="col">Status</th>
                                <th scope="col">Created</th>
                            </tr>
                            </thead>

What is the problem with the code?代码有什么问题? Anyone can do this, comment below.任何人都可以做到这一点,请在下面发表评论。

在此处输入图像描述

Try fixed-top instead.试试fixed-top It worked for me它对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM