当前位置:首页 > 网站应用 > 正文内容

字符乱码特效

cjw1231年前 (2024-10-15)网站应用2540
<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
        <title>字符乱码特效</title>
 </head>
 <style>
  * {
   margin: 0;
   padding: 0;
  }

  body {
   overflow: hidden;
  }
 </style>
 <body>
  <canvas id="canvas" width="1280" height="1024"> 您的浏览器不支持canvas标签,请您更换浏览器 </canvas>
 </body>
 <script>
  var canvas = document.getElementById("canvas");
  var can = canvas.getContext("2d");
  var s = window.screen;
  var w = canvas.width = s.width;
  var h = canvas.height = s.height;

  can.fillStyle = color2();

  var words = Array(256).join("1").split("");

  setInterval(draw, 50);

  function draw() {
   can.fillStyle = 'rgba(0,0,0,0.05)';
   can.fillRect(0, 0, w, h);
   can.fillStyle = color2();
   words.map(function(y, n) {
    text = String.fromCharCode(Math.ceil(65 + Math.random() * 57));
    x = n * 10;
    can.fillText(text, x, y)
    words[n] = (y > 758 + Math.random() * 484 ? 0 : y + 10);
   });
  }

  function color1() {
   var colors = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f'];
   var color = "";
   for (var i = 0; i < 6; i++) {
    var n = Math.ceil(Math.random() * 15);
    color += "" + colors[n];
   }
   return '#' + color;
  }

  function color2() {
   var color = Math.ceil(Math.random() * 16777215).toString(16);
   while (color.length < 6) {
    color = '0' + color;
   }
   return '#' + color;
  }

  function color3() {
   return "#" + (function(color) {
    return new Array(7 - color.length).join("0") + color;
   })((Math.random() * 0x1000000 << 0).toString(16))
  }
 </script>
</html>


扫描二维码推送至手机访问。

版权声明:本文由追求完美发布,如需转载请注明出处。

本文链接:https://cjw123.com/blog/?id=127

标签: htmlcss
分享给朋友:

相关文章

html meta标签屏蔽搜索引擎的用法

html页面中的 meta 标签可以用来识别搜索引擎的蜘蛛类型,可以规定meta标签所在的html页面是否被蜘蛛抓取,下面是这个meta标签的用法,大家可以借鉴一下。搜索引擎的 meta 标签的解析下面是meta标签对搜索引擎的解析<meta name='robot...

CSS头像的花式悬停效果

<html><head><style>img { --s:280px; /* image size */    --b:5px; /* border thic...

纯CSS实现侧边栏浮动在线客服效果

很多人一般在网页的侧边会选择放一个悬浮的在线客服,方便意向客户的联系,网上随便一搜也会有很多代码提供,但是大多都是JS书写的,并且夹带着一些图片素材乱七八糟的东西,用起来很不方便。今天我们就教给大家一个纯css书写的在线客服效果首先我们有如下html结构<div class=&quo...

google谷歌翻译镜像网站

查找外文资料对于外语不好的那必须要借助翻译工具,各家翻译工具各有不同,想要使用google谷歌翻译,奈何无法访问,那么如何在国内使用谷歌翻译?google谷歌翻译镜像网站有哪些?https://translate.yunkuerp.cn/https://translate.renwole.com/h...

霓虹灯

<!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">...

摇摆的灯光

点击运行看演示效果!<!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。