
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
© 版权声明:本文《css 随机渐变色》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686971778a411691.html。