这个能够无偿使用, 压缩后大概696字节,小脚本绝对不会拖累你的网站速度 , 你值得拥有!git
插件地址:bubbly-bg
预览地址:https://tipsy.github.io/bubbly-bggithub
在五彩缤纷的气泡页面背景中欣赏网站内容绝对近乎冥想的。
闲话不说,直接上代码,使用炒鸡炒鸡煎蛋。please往下看~~~
只要引入下面两行代码就会生成上面这个效果了npm
<script src="https://cdn.jsdelivr.net/npm/bubbly-bg@0.2.3/dist/bubbly-bg.js"></script> <script>bubbly();</script>
ps:bubbly()
是调用的其中一个方法,下面再介绍几个动画方法canvas
bubbly();
bubbly({ colorStart: "#111", colorStop: "#422", bubbleFunc: () => `hsla(0, 100%, 50%, ${Math.random() * 0.25})` });
bubbly({ colorStart: "#4c004c", colorStop: "#1a001a", bubbleFunc: () => `hsla(${Math.random() * 360}, 100%, 50%, ${Math.random() * 0.25})` });
bubbly({ colorStart: "#fff4e6", colorStop: "#ffe9e4", blur: 1, compose: "source-over", bubbleFunc: () => `hsla(${Math.random() * 50}, 100%, 50%, .3)` });
bubbly({ animate: true, // 动画 默认是正确的 blur: 4, // 默认的是4 bubbleFunc: () => `hsla(${Math.random() * 360}, 100%, 50%, ${Math.random() * 0.25})`, // 气泡函数 bubbles:100 , // 气泡数量 canvas: document.querySelector("#background"), // 默认是 created and attached colorStart: "#337ab7", //默认是 blue-ish 背景色左上角 colorStop: "#ff404b",//默认是 blue-ish 背景色右下角 compose: "lighter", //默认是 "lighter" shadowColor: "#0ff", //默认是 #fff });
还能够使用这个particles.js这个库
demodom