我如何在表的td内使用边距,但不使用边框折叠:单独

问题描述 投票:1回答:1

假设我要制作一张这样的桌子:you can see the color border have a separate color and margin inside the table data

如果使用border-collapse: separate属性,我已经可以做例子了,但行本身像这样被分隔开

you can see the top border

[当我使用border-collapse: collapse时,我可以使边框仍然存在,但不能自行设置边距

#home-table table {
  font-family: "Nunito", sans-serif;
  font-size: 1em;
  color: #1d3962;
  margin: 0% auto;
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
  max-width: 1200px;
  border: none;
  border-top: none;
}

#home-table .table-icon-img-size {
  width: 15px;
  height: 15px;
}

#home-table tr {
  border-top: solid 3px rgba(58, 115, 197, 0.1) !important;
}

#home-table th {
  font-size: 0.9em;
  color: #1d3962;
}

#home-table tr:nth-child(1) {
  border-top: none !important;
}

#home-table tr:nth-last-child(1) {
  border-bottom: none !important;
}

#home-table td {
  width: 25%;
}

#home-table .first {
  border-top: solid 3px rgba(58, 115, 197, 0.2) !important;
  border-top-radius: 10px;
}

#home-table td {
  margin: 0% 300px;
}

#home-table tr td:nth-child(1) {
  padding: 32px 38px;
  text-align: center;
}

#home-table tr th:nth-child(2) {
  text-align: center;
  font-weight: bold;
  background-color: rgba(46, 207, 47, 0.1);
  border-top-right-radius: 20px;
  border-top-left-radius: 20px;
  padding: 32px 38px;
}

#home-table tr td:nth-child(2) {
  background-color: rgba(46, 207, 47, 0.1);
  padding: 32px 38px;
  text-align: center;
}

#home-table tr th:nth-child(3) {
  text-align: center;
  font-weight: bold;
  background-color: rgba(219, 206, 44, 0.1);
  border-top-right-radius: 20px;
  border-top-left-radius: 20px;
  padding: 32px 38px;
}

#home-table tr td:nth-child(3) {
  background-color: rgba(219, 206, 44, 0.1);
  padding: 32px 38px;
  text-align: center;
}

#home-table tr th:nth-child(4) {
  text-align: center;
  font-weight: bold;
  background-color: rgba(229, 76, 110, 0.1);
  border-top-right-radius: 20px;
  border-top-left-radius: 20px;
  padding: 32px 38px;
}

#home-table tr td:nth-child(4) {
  text-align: center;
  color: #E54C6E;
  background-color: rgba(229, 76, 110, 0.1);
  padding: 32px 38px;
  margin: 0% 500px;
}

#home-table .test {
  padding-right: 20px;
}

#home-table tr td {
  padding: 32px 38px;
}
<div id="home-table">
  <div style="overflow-x:auto;">
    <table>
      <tr>
        <td>Diamond</td>
        <td>650</td>
        <td>500</td>
        <td>160</td>
      </tr>
      <tr>
        <td>Diamond</td>
        <td>650</td>
        <td>500</td>
        <td>160</td>
      </tr>
      <tr>
        <td>Diamond</td>
        <td>650</td>
        <td>500</td>
        <td>160</td>
      </tr>

    </table>
  </div>
</div>

有人可以帮我解决这个问题吗?我对此问题很困惑

html css
1个回答
0
投票

我正在尝试解决您的问题,请检查此链接:demo

© www.soinside.com 2019 - 2024. All rights reserved.