我需要为单个边框设置多种颜色,如下所示。但在这里我在tr中使用了三个td元素。我需要一个单独的td元素,边框必须是它的(td' s)底部或顶部边框。
<table style="border-spacing:0px;margin-top:5%;margin-left:2%" cellpadding="0" width="25%">
<tbody>
<tr>
<td width="5%" style="border-bottom: 3px solid red;"> </td>
<td width="90%" style="border-bottom: 3px solid green;">
</td>
<td width="5%" style="border-bottom: 3px solid red;"> </td>
</tr>
</tbody>
</table>
&#13;
答案 0 :(得分:2)
你可以通过以下方式来做。请检查。
.test {
width: 500px;
height: 100px;
background-color: #ccc;
position: relative;
}
.test:before, .test:after {
content: "";
position: absolute;
left: 0px;
right: 0px;
height: 10px;
background-image: -webkit-linear-gradient(0deg, red 20px, blue 20px, blue 40px, yellow 40px, yellow 60px, green 60px, green 80px);
background-image: -ms-linear-gradient(0deg, red 20px, blue 20px, blue 40px, yellow 40px, yellow 60px, green 60px, green 80px);
background-size: 80px;
}
.test:before {
top: 0px;
}
.test:after {
bottom: 0px;
}
&#13;
<table>
<tr>
<td class="test">
1
</td>
<td class="test">
2
</td>
</tr>
</table>
&#13;
答案 1 :(得分:1)
使用CSS border
属性,我们可以创建仅具有单色的边框。但是我们可以通过使用CSS3来模仿这种效果。
使用linear-gradient()
,我们可以根据需要创建具有多种颜色的光谱。
以下是几个例子:
边框有两种颜色:
必要的CSS:
background-image: linear-gradient(to right, red 50%, green 50%);
<强>截图:强>
工作示例:
td {
padding: 10px;
background: linear-gradient(to right, red 10%, green 10%, green 90%, red 90%) no-repeat;
background-size: 100% 3px;
background-position: left bottom;
}
&#13;
<table style="border-spacing:0px;margin-top:5%;margin-left:2%" cellpadding="0" width="25%">
<tbody>
<tr>
<td>Some text here</td>
</tr>
<tr>
<td>Some text here</td>
</tr>
</tbody>
</table>
&#13;
边框有3种颜色:
必要的CSS:
background-image: linear-gradient(to right, red 33.33%, green 33.33%,
green 66.67%, red 66.67%);
<强>截图:强>
工作示例:
td {
padding: 10px;
background: linear-gradient(to right, red 33.33%, green 33.33%, green 66.67%, red 66.67%) no-repeat;
background-size: 100% 3px;
background-position: left bottom;
}
&#13;
<table style="border-spacing:0px;margin-top:5%;margin-left:2%" cellpadding="0" width="25%">
<tbody>
<tr>
<td>Some text here</td>
</tr>
<tr>
<td>Some text here</td>
</tr>
</tbody>
</table>
&#13;
答案 2 :(得分:0)
您可以使用伪类:
-r tracefile pattern
--remove tracefile pattern
Remove data from tracefile.
&#13;
-e EXCLUDE, --exclude=EXCLUDE
Exclude data files that match this regular expression
&#13;
答案 3 :(得分:0)
<table style="border-spacing:0px;margin-top:5%;margin-left:2%" cellpadding="0" width="25%">
<tbody>
<tr>
<td width="5%" style="border-left: 3px solid red;border-right: 3px solid red; border-top: 3px solid green;border-bottom: 3px solid green;">text </td>
</tr>
</tbody>
</table>
&#13;
答案 4 :(得分:0)
您可以这样做,设置常规边框并使用:before
和:after
伪元素来创建红色部分。
table {
width: 25%;
}
td {
border-bottom: 3px solid green;
position: relative;
}
td:before,
td:after {
border-bottom: 3px solid red;
content: "";
display: block;
width: 5%;
position: absolute;
bottom: -3px;
}
td:before {
left: 0;
}
td:after {
right: 0;
}
&#13;
<table>
<tr>
<td>
</td>
</tr>
</table>
&#13;