首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在bootstrap -5中将背景色添加到表头

无法在bootstrap -5中将背景色添加到表头
EN

Stack Overflow用户
提问于 2021-06-20 14:20:09
回答 1查看 241关注 0票数 0

我正在尝试将背景颜色添加到bootstrap表。它不会应用它。

代码语言:javascript
复制
 <table class="table table-dark table-hover">
        <thead class="bg-info text-white">
          <tr>
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
          </tr>
        </thead>
</table>

我也试过了

代码语言:javascript
复制
    <tr class="bg-info text-white">

它不工作。

我正在使用bootstrap-5。

这里出了什么问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-20 14:48:31

这是因为您在<table>中使用了table-dark,它覆盖了<thead>上的任何其他样式。

要查看bg-info<thead>中的运行情况,必须先删除table-dark

代码语言:javascript
复制
<link href="https://getbootstrap.com/docs/5.0/dist/css/bootstrap.min.css" rel="stylesheet"/>

<!--With table-dark-->
 <table class="table table-dark table-hover">
   <thead class="bg-info text-white">
       <tr>
           <th scope="col">#</th>
           <th scope="col">First</th>
           <th scope="col">Last</th>
           <th scope="col">Handle</th>
       </tr>
   </thead>
</table>

<!--Without table-dark-->
<table class="table table-hover">
   <thead class="bg-info text-white">
       <tr>
           <th scope="col">#</th>
           <th scope="col">First</th>
           <th scope="col">Last</th>
           <th scope="col">Handle</th>
       </tr>
   </thead>
</table>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68053188

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档