【问题标题】:How to put border color as Linear Gradient on Table Row's border? [duplicate]如何将边框颜色作为线性渐变放在表格行的边框上? [复制]
【发布时间】:2020-12-25 11:40:47
【问题描述】:

我正在尝试将表格行的边框颜色设置为线性渐变。表格代码如下:

td:first-child {
 border-left: 1px solid black;
 border-bottom-left-radius: 50px;
 border-top-left-radius: 50px;
}

td:last-child {
 border-right: 1px solid black;
 border-bottom-right-radius: 50px;
 border-top-right-radius: 50px;
}

td {
 padding-left: 4%;
 border-top: 1px solid black;
 border-bottom: 1px solid black;
}

我知道我可能需要分别放在第一个、最后一个孩子以及 td 类上。

我在表数据(td)上尝试过以下代码,但没有运气。此代码填充内部表格数据背景而不是边框​​颜色。:

td {
 border-top: 1px solid black;
 border-bottom: 1px solid black;
 border: 1px solid transparent;
 border-radius: 100px;
 background-image: linear-gradient(white, white),
 linear-gradient(178.18deg, #fd749b -13.56%, #281ac8 158.3%);
 background-origin: border-box;
 background-clip: content-box, border-box;
}

预期输出:

【问题讨论】:

  • 能否添加相关的html代码?

标签: css html-table


【解决方案1】:

请试试这个,

这是表格的演示,

td:first-child {
 border-left: 1px solid black;
 border-bottom-left-radius: 50px;
 border-top-left-radius: 50px;
}

td:last-child {
 border-right: 1px solid black;
 border-bottom-right-radius: 50px;
 border-top-right-radius: 50px;
}
td {
 text-indent:5%;
 border-top: 1px solid black;
 border-bottom: 1px solid black;
 border: 1px solid transparent;
 border-radius: 50px;
 background-image: linear-gradient(white, white),
 linear-gradient(178.18deg, #fd749b -13.56%, #281ac8 158.3%);
 background-origin: border-box;
 background-clip: content-box, border-box;
}
<table>
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>John</td>
    <td>Dalton</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>

【讨论】:

  • 请添加预期输出的屏幕截图或图像。
  • 感谢您的回复。我添加了一个屏幕截图。请检查。我的 HTML 代码与您的相同,所以没关系。顺便说一句,我希望渐变像截图一样只停留在边界半径上。
猜你喜欢
  • 1970-01-01
  • 2018-12-27
  • 1970-01-01
  • 2016-12-15
  • 2021-03-18
  • 1970-01-01
  • 2019-12-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多