border-top-color
为#9b9c9d
,border-bottom-color
为#f6f9fc
。渐变意图将顶部颜色转换为border-left
和border-right
上的底部颜色。
如何将border-left-image
和border-right-image
与border-top-color
和border-bottom-color
混合?
HTML
<a class="button-style">Evil Whales</a>
CSS
.button-style
{
background: linear-gradient(to bottom,
rgba(129,232,117,1) 0%,
rgba(129,232,117,1) 50%,
rgba(62,179,48,1) 51%,
rgba(62,179,48,1) 100%);
border-top-color: #9b9c9d;
border-left-image: linear-gradient(to bottom,
rgba(155,156,157,1) 0%,
rgba(246,249,252,1) 100%);
border-bottom-color: #f6f9fc;
border-right-image: linear-gradient(to bottom,
rgba(155,156,157,1) 0%,
rgba(246,249,252,1) 100%);
border-style: solid;
}
答案 0 :(得分:0)
虽然只是在Chrome中工作,但Firefox和IE都无法正常工作。
background: linear-gradient(to bottom,
rgba(129,232,117,1) 0%,
rgba(129,232,117,1) 50%,
rgba(62,179,48,1) 51%,
rgba(62,179,48,1) 100%);
border-image: linear-gradient(to bottom,
rgba(155,156,157,1) 0%,
rgba(246,249,252,1) 100%) 25 30 10 20 repeat;
border-image-repeat: stretch;
border-width: 4px;
应该注意的是,没有border-left-image
和相关的属性;遗憾的是,这不是更好的CSS属性之一。
答案 1 :(得分:0)
您可以叠加2个渐变并使用background-size
,padding
&amp; background-clip
来绘制border
。
.button-style {
background: linear-gradient(to bottom, rgba(129, 232, 117, 1) 0%, rgba(129, 232, 117, 1) 50%, rgba(62, 179, 48, 1) 51%, rgba(62, 179, 48, 1) 100%) no-repeat
/* use for background */
, linear-gradient(to bottom, rgba(155, 156, 157, 1) 0%, rgba(246, 249, 252, 1) 100%)
/* use for border */
;
background-size: 100% 100%, auto auto;
background-clip: content-box, border-box;
padding: 3px;
}
html {
padding: 3em;
background: gray;
&#13;
<a class="button-style">Evil Whales</a>
&#13;