【问题标题】:Table borders not showing up表格边框不显示
【发布时间】:2015-09-11 11:22:40
【问题描述】:

我正在尝试设置表格的样式,但没有显示边框。我以前从来没有遇到过这种情况,所以我不知道该怎么办。

这是我的桌子:

<table class="table">
  <thead>
    <tr>
      <th>Dessert (100g serving)</th>
      <th>Calories</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Dessert (100g serving)</td>
      <td>Calories</td>
    </tr>
  </tbody>
</table>

这是我的更少:

@dark-text: rgba(0,0,0,0.87);
@dark-text-secondary: rgba(0,0,0,0.54);
@dark-text-disabled: rgba(0,0,0,0.26);

.table {
    z-index: 10;

    thead {
        tr {
            border-bottom: 3px solid @dark-text-disabled;
            z-index: 10;

            th {
                color: @dark-text-secondary;
                z-index: 10;
            }
        }
    }

    tbody {
        tr {
            border-bottom: 3px solid @dark-text-disabled;
            z-index: 10;

            td {
                z-index: 10;
            }
        }
    }
}

http://codepen.io/anon/pen/JdOaVO

【问题讨论】:

  • 我相信你应该设置td而不是tr,然后border-collapse: collapse来消除行之间的间隙。
  • @Huey 如果我在 Chrome 中使用 Inspect Element,我可以看到边框的高亮显示,但否则我看不到它。

标签: html css less


【解决方案1】:

要么将border-bottom 规则移动到thtd 标记,要么对.table 使用collapsing border model (border-collapse: collapse;)

.table {
    border-collapse: collapse;
}

http://codepen.io/anon/pen/BNmOgg

【讨论】:

    猜你喜欢
    • 2011-11-02
    • 2015-07-06
    • 2014-09-14
    • 2021-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-23
    • 2020-05-24
    相关资源
    最近更新 更多