关于javascript:代码片段

产生随机色彩
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;
}

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理