2016-03-10 35 views
0

#9b9c9dborder-bottom-color#f6f9fc。梯度爲,意圖爲以將頂部顏色轉換爲border-leftborder-right上的底部顏色。border-left-image和border-right-image與邊框顏色混合的CSS邊框圖像漸變

如何混合border-left-imageborder-right-image與和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

請添加代碼的起點。 – Roy

回答

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屬性。

+0

使用'border-image'時,所有4個邊框都使用相同的圖像。它主要用於像圖片圖像的情況。但是,使用附加屬性可以實現多種效果。 (切片,寬度,起始和重複)。 –

0

可在堆疊2梯度和使用background-sizepadding & 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;
<a class="button-style">Evil Whales</a>