有一個叫border CSS屬性,它需要一個PARAM厚度,邊框的類型和邊框的顏色
,如果你想使用一個漸變使用CSS屬性border-image
<div class="box">
hey there
</div>
CSS:
.box{
width: 250px;
height: 20px;
background: transparent;
border-bottom: 5px solid transparent;
-moz-border-image: -moz-linear-gradient(left, rgba(0,0,0,0) 1%, rgba(0,0,0,0.65) 24%, rgba(0,0,0,0.65) 50%, rgba(0,0,0,0.65) 51%, rgba(0,0,0,0.65) 75%, rgba(0,0,0,0) 100%);
-webkit-border-image: -webkit-linear-gradient(left, rgba(0,0,0,0) 1%, rgba(0,0,0,0.65) 24%, rgba(0,0,0,0.65) 50%, rgba(0,0,0,0.65) 51%, rgba(0,0,0,0.65) 75%, rgba(0,0,0,0) 100%);
border-image: linear-gradient(left, rgba(0,0,0,0) 1%, rgba(0,0,0,0.65) 24%, rgba(0,0,0,0.65) 50%, rgba(0,0,0,0.65) 51%, rgba(0,0,0,0.65) 75%, rgba(0,0,0,0) 100%);
border-image-slice: 1;
}
http://jsfiddle.net/agkety8w/
在您的情況執行以下操作: 梯度:
return 'linear-gradient(to left, '+c1.rgb+' 0%, '+c2.rgb+' 50%, '+c1.rgb+'
功能:
function PPAP() {
elements = $('li');
elements.each(function() { $(this).css({"borderImage":random(), "borderImageSlice": "1","borderBottom": "5px solid transparent"}); });
}
https://jsfiddle.net/tdeqvoaa/
你的意思是這樣'elements.each(函數(){$(本)的.css( 「邊界」,隨機()); });'? – Newbi
您將需要漸變的邊框圖像屬性 – madalinivascu
我已更新我的答案 – madalinivascu