admin管理员组

文章数量:1794759

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))' }; } }

参考菜鸟教程官网

最后一位是透明度 

本文标签: 渐变色css