关于javascript:代码片段

46次阅读

共计 589 个字符,预计需要花费 2 分钟才能阅读完成。

产生随机色彩
function randomVal(val) {return Math.floor(Math.random() * (val + 1));
}
   
function randomColor() {return `rgb(${randomVal(255}, ${randomVal(255}, ${randomVal(255})`;
}
渐变色按钮
<button class="btn">
    <span> 突变按钮 </span>
</button>

.btn {
    padding: 1px;
    color: #4cdbbc;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    border: none;
    background: -webkit-linear-gradient(left, #fff 0%, #fff 100%), linear-gradient(90deg, #47d998 0%, #01d5d8 100%);
    background-clip: content-box, padding-box;
}
.btn span {background: linear-gradient(90deg, #47d998 0%, #01d5d8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

正文完
 0