✅ 操作成功!

css 随机渐变色

发布时间:2023-06-17 作者:admin 来源:文学

css 随机渐变色

css 随机渐变色

效果图:

 代码:

1.给div绑定一个动态的style

:style="bgColorFor(item)

2.方法

methods:{ //随机渐变色 bgColorFor(item){ let R = Math.floor(Math.random() * 130+110); let G = Math.floor(Math.random() * 130+110); let B = Math.floor(Math.random() * 130+110); return { background: 'linear-gradient(to right, #fff, rgba(' + R + ',' + B + ',' + G + ',0.5))' }; } }

参考菜鸟教程官网

最后一位是透明度 

👁️ 阅读量:0