1

铬合金

在此处输入图像描述

火狐

在此处输入图像描述

我可以做些什么来更改我的代码,使其在 Firefox 中具有 Chrome 外观?我正在使用伪元素来模仿重叠表行的外观。如果可以在不使用伪元素的情况下实现这种外观,那么这也是一个适合我的解决方案。

th:first-child, tbody td:first-child {
  border-top-left-radius: 1.5rem;
}
th:last-child, tbody td:last-child {
  border-top-right-radius: 1.5rem;
}
tbody, tbody td {
  position: relative;
  z-index: 10;
  transform: scale( 1 );
  background-color: #333;
}
tbody td:first-child, tfoot td:first-child {
  border-bottom-left-radius: 1.5rem;
}
tbody td:last-child, tfoot td:last-child {
  border-bottom-right-radius: 1.5rem;
}
tbody::before, tbody::after {
  position: absolute;
  z-index: -10;
  top: 0; right: 0; bottom: 50%; left: 0;
  background-color: #222;
  content: "";
}
tbody::after {
  top: 50%; right: 0; bottom: 0; left: 0;
  background-color: #444;
}
tfoot {
  background-color: #444;
}
<style>
  html, table, p {
    margin: 0;
    padding: 0 !important;
    color: #ddd;
  }
  html {
    font-family: Arial;
    text-align: center;
    text-transform: capitalize;
  }
  table, th, td {
    padding: 1rem;
    border-spacing: 0;
  }
  thead {
    background-color: #222;
  }
  th { text-transform: uppercase; }
  td { border-bottom: solid #222; }
</style>
<table>
  <thead>
    <tr> <th><p>one</p></th><th><p>two</p></th><th><p>three</p></th> </tr>
  </thead>
  <tbody>
    <tr> <td><p>four</p></td><td><p>five</p></td><td><p>six</p></td> </tr>
  </tbody>
  <tfoot>
    <tr> <td><p>seven</p></td><td><p>eight</p></td><td><p>nine</p></td> </tr>
  </tfoot>
</table>

4

2 回答 2

1

实际上工作正常。只需设置background:red并查看它。

thead th:first-child, tbody td:first-child {
  border-top-left-radius: 1.5rem;
  background:red;
}
th:last-child, tbody td:last-child {
  border-top-right-radius: 1.5rem;
}
tbody, tbody td {
  position: relative;
  z-index: 10;
  transform: scale( 1 );
  background-color: #333;
}
tbody td:first-child, tfoot td:first-child {
  border-bottom-left-radius: 1.5rem;
}
tbody td:last-child, tfoot td:last-child {
  border-bottom-right-radius: 1.5rem;
}
tbody::before, tbody::after {
  position: absolute;
  z-index: -10;
  top: 0; right: 0; bottom: 50%; left: 0;
  background-color: #222;
  content: "";
}
tbody::after {
  top: 50%; right: 0; bottom: 0; left: 0;
  background-color: #444;
}
tfoot {
  background-color: #444;
}
<style>
  html, table, p {
    margin: 0;
    padding: 0 !important;
    color: #ddd;
  }
  html {
    font-family: Arial;
    text-align: center;
    text-transform: capitalize;
  }
  table, th, td {
    padding: 1rem;
    border-spacing: 0;
  }
  thead {
    background-color: #222;
  }
  th { text-transform: uppercase; }
  td { border-bottom: solid #222; }
</style>
<table>
  <thead>
    <tr> <th><p>one</p></th><th><p>two</p></th><th><p>three</p></th> </tr>
  </thead>
  <tbody>
    <tr> <td><p>four</p></td><td><p>five</p></td><td><p>six</p></td> </tr>
  </tbody>
  <tfoot>
    <tr> <td><p>seven</p></td><td><p>eight</p></td><td><p>nine</p></td> </tr>
  </tfoot>
</table>

发生这种情况是因为您设置了thead { background-color: #222;}. 使用th而不是thead. 请参阅下面的片段。

thead th:first-child,
tbody td:first-child {
  border-top-left-radius: 1.5rem;
}

th:last-child,
tbody td:last-child {
  border-top-right-radius: 1.5rem;
}

tbody,
tbody td {
  position: relative;
  z-index: 10;
  transform: scale( 1);
  background-color: #333;
}

tbody td:first-child,
tfoot td:first-child {
  border-bottom-left-radius: 1.5rem;
}

tbody td:last-child,
tfoot td:last-child {
  border-bottom-right-radius: 1.5rem;
}

tbody::before,
tbody::after {
  position: absolute;
  z-index: -10;
  top: 0;
  right: 0;
  bottom: 50%;
  left: 0;
  background-color: #222;
  content: "";
}

tbody::after {
  top: 50%;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: #444;
}

tfoot {
  background-color: #444;
}
<style>
  html,
  table,
  p {
    margin: 0;
    padding: 0 !important;
    color: #ddd;
  }
  
  html {
    font-family: Arial;
    text-align: center;
    text-transform: capitalize;
  }
  
  table,
  th,
  td {
    padding: 1rem;
    border-spacing: 0;
  }
  
  th {
    background-color: #222;
  }
  
  th {
    text-transform: uppercase;
  }
  
  td {
    border-bottom: solid #222;
  }
</style>
<table>
  <thead>
    <tr>
      <th>
        <p>one</p>
      </th>
      <th>
        <p>two</p>
      </th>
      <th>
        <p>three</p>
      </th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        <p>four</p>
      </td>
      <td>
        <p>five</p>
      </td>
      <td>
        <p>six</p>
      </td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td>
        <p>seven</p>
      </td>
      <td>
        <p>eight</p>
      </td>
      <td>
        <p>nine</p>
      </td>
    </tr>
  </tfoot>
</table>

于 2020-11-18T05:55:36.507 回答
-1

在您的代码中也附加这些行:-

border-top-left-radius: 1.5rem;
-moz-border-radius-topleft: 1.5rem;
-webkit-border-top-left-radius: 1.5rem;

对其他半径做同样的事情。原因是 Firefox、Internet Explorer(IE9 之前)、Safari 不支持很多 CSS3 属性。您需要添加供应商前缀(-moz、-webkit)才能使用 Firefox 和 Safari。

于 2020-11-18T05:46:56.040 回答