在博客设置 页脚HTML代码 贴入如下代码
!--黑客帝国背景移动端不加入-- divcanvas idmatrixBG /canvas/div script srchttps://files.cnblogs.com/files/batsing/matrix.js/script script $(function(){ let ua navigator.userAgent.toLowerCase(); if( ua.indexOf(mobile)0 ){ window.onload function(){ let matrix new MatrixBG(matrixBG, 2); } } }); /script其中引入的 matrix.js 是已封装好的核心代码引入的关键是let matrix new MatrixBG(matrixBG, 2);其中matrixBG 是canvas标签的id后面的2是指用第2类背景字符彝文。matrix.js内置了三种字符1是注音字符2是彝文3是英文数字。可以自行测试不同文字的效果我目前偏好彝文的效果如果需要更多的字符可以自行下载修改代码添加如藏文、蒙古文、梵文等。特别安利一下彝族歌手约里一朵云乐队的歌好听又有民族风格另外彝族海来阿木的歌也不错。四、在 页面定制CSS代码 贴入如下代码body { background: url(//photo.tuchong.com/1019978/f/21914120.jpg) fixed center center; background-repeat: no-repeat; background-size: cover; } #matrixBG{ position: fixed; top:0; left: 0; z-index: -1; animation: fade8 3s infinite; } keyframes fade8 { 0% { opacity: 0.8; } 50% { opacity: 0.9; } 100% { opacity: 0.8; } }body添加了一张背景图是广东省博物馆的夜景照片暗红色作为背景增加氛围感。