简体   繁体   English

如何防止此表格行出现在表格标题后面?

[英]How can I prevent this table row from appearing behind my table header?

My goal is to apply sticky headers to a table using a pure CSS approach.我的目标是使用纯 CSS 方法将粘性标题应用于表格。

Using this as a guide.以此为指导。 Table fixed header and scrollable body 表格固定标题和可滚动正文

When the page renders the table looks fine, when I start scrolling you can see a sliver of the data above the table header.当页面呈现表格时看起来不错,当我开始滚动时,您可以看到表格标题上方的一小段数据。

开始滚动后,您可以看到出现在 <th> 上方的文本

 <div class="large-12 columns" ng-show="$ctrl.filteredParticipantsDt.length != 0">
    <div style="max-height: 260px; overflow: auto;" class="tableFixHead">
        <table border="1" style="width: 100%" >
            <thead>
                <tr>
                <th><a ng-click="$ctrl.orderByField='ID_NBR'; $ctrl.reverseSort = !$ctrl.reverseSort" refresh-session>IDENTIFIER
                    <span ng-show="$ctrl.orderByField == 'ID_NBR'"><span ng-show="!$ctrl.reverseSort" class="fi-arrow-up"></span><span ng-show="$ctrl.reverseSort" class="fi-arrow-down"></span></span></a></th>
                <th><a ng-click="$ctrl.orderByField='CNCAT_LST_FRST_M_I'; $ctrl.reverseSort = !$ctrl.reverseSort" refresh-session>PERSON
                    <span ng-show="$ctrl.orderByField == 'CNCAT_LST_FRST_M_I'"><span ng-show="!$ctrl.reverseSort" class="fi-arrow-up"></span><span ng-show="$ctrl.reverseSort" class="fi-arrow-down"></span></span></a></th>
                <th><a ng-click="$ctrl.orderByField='SHRT_DESC'; $ctrl.reverseSort = !$ctrl.reverseSort" refresh-session>ROLE
                    <span ng-show="$ctrl.orderByField == 'SHRT_DESC'"><span ng-show="!$ctrl.reverseSort" class="fi-arrow-up"></span><span ng-show="$ctrl.reverseSort" class="fi-arrow-down"></span></span></a></th>
                <th><a ng-click="$ctrl.orderByField='EFF_DT'; $ctrl.reverseSort = !$ctrl.reverseSort" refresh-session>EFFECTIVE DATE
                    <span ng-show="$ctrl.orderByField == 'EFF_DT'"><span ng-show="!$ctrl.reverseSort" class="fi-arrow-up"></span><span ng-show="$ctrl.reverseSort" class="fi-arrow-down"></span></span></a></th>
                <th><a ng-click="$ctrl.orderByField='END_DT'; $ctrl.reverseSort = !$ctrl.reverseSort" refresh-session>END DATE
                    <span ng-show="$ctrl.orderByField == 'END_DT'"><span ng-show="!$ctrl.reverseSort" class="fi-arrow-up"></span><span ng-show="$ctrl.reverseSort" class="fi-arrow-down"></span></span></a></th>
                </tr>
    </thead>
    <tbody>                
        <tr ng-repeat="a in $ctrl.filteredParticipantsDt|orderBy:$ctrl.orderByField:!$ctrl.reverseSort" 
            ng-click="$ctrl.setSelected(a)" 
            ng-class="{Highlight: a.PCR_ID === $ctrl.Selected.PCR_ID, endDatedRow: a.END_DATED_IND == 'Y'}" refresh-session>
                <td>{{a.ID_NBR}}</td>
                <td>{{ a.CNCAT_LST_FRST_M_I }}</td>
                <td>{{a.SHRT_DESC}}</td>
                <td>{{a.DISPLAYEFF}}</td>
                <td>{{a.DISPLAYEND || ''}}</td>
                </tr>               
            </tbody>
        </table>
    </div> 
</div>

I know its a bit late to answer, but I had this exact issue.我知道回答有点晚了,但我遇到了这个确切的问题。 The problem is the table header has an invisible border that needs to be removed in order to not see that extra pixel behind it.问题是表格标题有一个不可见的边框,需要删除它才能看不到它后面的额外像素。 The inline solution for brevity sake:为简洁起见,内联解决方案:

<div class="large-12 columns" ng-show="$ctrl.filteredParticipantsDt.length != 0">
<div style="max-height: 260px; overflow: auto;" class="tableFixHead">
    <table border="1" style="width: 100%" >
        <thead>
            <tr(style="border-style:hidden")>
. . .

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

相关问题 如何阻止我的 HTML 水平表(使用 mini.css)内容消失在 header 后面 - How can I stop my HTML horizontal table (using mini.css) content vanishing behind the header 如何防止背景色/图像出现在上一行(引导程序) - How do I prevent my background colour/image from appearing in the previous row (bootstrap) 如何防止嵌套表扩大父表? - How can I prevent a nested table from enlarging the parent table? 如何防止来自不同表格的文本出现在图片上 html email 代码 - How do I prevent text from different table from appearing on a picture html email code 如何防止td中的文本破坏表格的对齐方式? - How can I prevent the text inside my td from destroying my table's alignment? 我怎样才能从这张桌子上刮下一行 - How can I scrape a row from this table 如何防止表格中的该div增加单元格高度? - How can I prevent this div in my table from increasing the cell height? 如何强制标题表行与其他表行的高度相同? - How do I force my header table row to be the same height as the other table rows? 如何防止第一个孩子的CSS也影响HTML表中的第二个孩子? - How can I prevent first-child CSS from also affecting the second child in my HTML Table? 如何将标头添加到JSON输出表中? - How can I add a header to my JSON output table?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM