Border around tr element doesn't show?

后端 未结 1 947
礼貌的吻别
礼貌的吻别 2020-12-04 11:18

It seems like Chrome/Firefox do not render borders on tr, but it renders the border if the selector is table tr td.

How can I set a border

相关标签:
1条回答
  • 2020-12-04 11:53

    Add this to the stylesheet:

    table {
      border-collapse: collapse;
    }
    

    JSFiddle.

    The reason why it behaves this way is actually described pretty well in the specification:

    There are two distinct models for setting borders on table cells in CSS. One is most suitable for so-called separated borders around individual cells, the other is suitable for borders that are continuous from one end of the table to the other.

    ... and later, for collapse setting:

    In the collapsing border model, it is possible to specify borders that surround all or part of a cell, row, row group, column, and column group.

    0 讨论(0)
提交回复
热议问题