簡體   English   中英

有沒有辦法為特定像素創建css3邊框漸變?

[英]Is there a way to create a css3 border gradient to a specific pixel?

我知道這可能與背景漸變有關,但無法弄清楚如何為邊框漸變實現這一點。

這是我到目前為止所擁有的

-webkit-border-image  : -webkit-gradient(linear, 0 0, 0 100%, from(#666), to(#000)) 1 100%; 
-webkit-border-image  : -webkit-linear-gradient(#666, #000) 1 100%; 
-moz-border-image     : -moz-linear-gradient(#666, #000) 1 100%; 
-o-border-image       : -o-linear-gradient(#666, #000) 1 100%; 
border-image          : linear-gradient(to bottom, #666, #000) 1 100%;

我想從底部向上的第一個32px是黑色,然后其余的向上灰色(#666)。

這是我希望我的右邊界看起來像什么的一個例子

我建議你這樣做:使用一個pseudo-element :before:before定位在bottom:0left:-15px ,因為15px是邊框的寬度。 如果更改border-width ,則left:-15px更改left:-15px

它的width:15px相同width:15px

我使用width:15pxbackground:#000但你可以簡單地使用border-left:15px solid #000而不是那兩個。 結果是一樣的。

 .borderme { position:relative; height:300px; border-left:15px solid #666; } .borderme:before { position:absolute; height:32px; width:15px; background:#000; bottom:0; left:-15px; content:""; } 
 <div class="borderme"> </div> 

檢查此站點 ,您可以在其中創建css漸變並獲取代碼並粘貼到您的CSS中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM