首页 > 解决方案 > 表条带引导类不工作,但其他类正在工作

问题描述

我在一个角度项目中使用引导类创建了一个表。只有 table-striped 和 table-hover 类不工作,其余类如 table-primary 工作。而且我还没有写过一行 css 代码(没有覆盖问题)。我已经尝试了堆栈中的其他示例,但没有解决问题出在 tbody 上。我试过包括 tbody 标签但没有用。

<div class="container box" style="margin-top: 10px;">
                <table class="table table-striped table-fit table-bordered table-hover">
                    <thead> 
                        <tr> 
                            <th>Item</th> 
                            <th>Amount</th> 
                            <th>Category</th> 
                            <th>Location</th> 
                            <th>Spent On</th> 
                        </tr> 
                        
                            <tr *ngFor="let entry of expenseEntries">
                                <th scope="row">{{ entry.item }}</th>
                                <th>{{ entry.amount }}</th> 
                                <td>{{ entry.category }}</td> 
                                <td>{{ entry.location }}</td>
                                <td>{{ entry.spendOn | date: 'short' }}</td>
                            </tr>
                      
                    </thead>
                </table>
            </div>

标签: htmlcssnode.jsangularbootstrap-4

解决方案


您必须在标签内定义<thead>和标签。<tbody><table>

tbody内的表格内容只会受官方文档.table-striped中提到的class影响


推荐阅读