【问题标题】:Bootstrap forcing table stripingBootstrap 强制表条带化
【发布时间】:2018-05-27 20:12:42
【问题描述】:

我在一张桌子里面有一张桌子。在外面的桌子上我想要条纹和边框,但在里面的桌子上我不想要。我这样做了。

<table class="table table-bordered table-sm table-striped">
  <tbody>
      <tr>
          <td>
              <table class="table table-sm table-borderless" style="margin: 0">

外部 内部表都有条带化。如何强制该内表没有条纹或边框?

【问题讨论】:

  • 你能在这里分享完整的代码吗
  • 你知道如何在互联网上的 css 中检查任何类的定义,如“table-striped”我可能尝试了很多事情,但我从内部表中删除了边框,但无法正确处理

标签: bootstrap-4


【解决方案1】:

根据Bootstrap docs...

"所有表格样式都在 Bootstrap 4 中继承,意味着任何嵌套 表格的样式将与父表格相同。”

因此,为了覆盖嵌套表格上的条纹,您必须添加一点 CSS...

.table-nostriped tbody tr:nth-of-type(odd) {
  background-color:transparent;
}

<table class="table table-bordered table-sm table-striped">
    <tbody>
        <tr>
            <td>
                <table class="table table-sm table-borderless table-nostriped">
                </table>
            </td>
        </tr>
    </tbody>
</table>

https://www.codeply.com/go/95b4ecfFP7

【讨论】:

  • 我用 opacity 试过了没用,你能说我是否可以在某处观看引导 css 的类定义吗?
  • 平均定义
  • @ZimSystem 这确实使条纹消失,但似乎出于某种原因将背景强制为白色。例如,父表行是浅灰色的,但是这个 td 元素全是白色的。
  • 这个解决方案,结合从嵌套表中删除“table”类为我做了它(如here所示)
猜你喜欢
  • 2015-01-17
  • 2014-08-29
  • 2015-07-19
  • 1970-01-01
  • 1970-01-01
  • 2014-08-10
  • 2015-10-14
  • 2011-05-20
  • 1970-01-01
相关资源
最近更新 更多