Borders not shown in Firefox with border-collapse on table, position: relative on tbody, or background-color on cell

后端 未结 7 2054
余生分开走
余生分开走 2020-11-30 01:58

Consider the following HTML:

<
7条回答
  •  孤独总比滥情好
    2020-11-30 02:36

    The best way to solve this issue is to do something like this.

    Note the position: relative property in the "thead" and the "tbody' elements, those are important. So are the border-collapse and background-clip properties. Works with background-color on all and alternating rows.

    table {
      width: 100% !important;
      border-spacing: 0;
      border-collapse: unset !important;
    
      thead {
        position: relative;
        left: -1px;
        top: -1px;
    
        tr {
          th {
            background-clip: padding-box;
            border-top: 1px solid #737373!important;
            border-left: 1px solid #737373!important;
            border-right: none !important;
            border-bottom: none !important;
    
            &:last-child {
              border-right: 1px solid #737373!important;
            }
          }
        }
      }
    
      tbody {
        position: relative;
        left: -1px;
        top: -1px;
    
        tr {
          &:last-child {
            td {
              border-bottom: 1px solid #737373!important;
            }
          }
    
          td {
            background-clip: padding-box;
            border-top: 1px solid #737373!important;
            border-left: 1px solid #737373!important;
            border-right: none !important;
            border-bottom: none !important;
    
            &:last-child {
              border-right: 1px solid #737373!important;
            }
          }
        }
      }
    }
    

提交回复
热议问题