js实现鼠标悬浮文字字母变化动画效果代码

代码语言:html

所属分类:悬停

代码描述:js实现鼠标悬浮文字字母变化动画效果代码

代码标签: js 鼠标 悬浮 文字 字母 变化 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">




    <style>
        @import url("https://fonts.googleapis.com/css2?family=Space+Mono&display=swap");
        body {
          align-items: center;
          background: linear-gradient(225deg, #004e92 16%, #000d7a 100%);
          display: flex;
          height: 100vh;
          justify-content: center;
        }
        body a {
          color: #ffdd40;
          display: inline-block;
          font-family: "Space Mono", monospace;
          font-size: 36px;
          letter-spacing: 5px;
          margin: 0 10px;
          padding: 2px 12px 6px 19px;
          position: relative;
          text-decoration: none;
        }
    </style>






</head>

<body>
    <a href="#" class="cipher">Hover Me!</a>


    <script>
        const links = document.querySelectorAll("a.cipher");
        const solveMilliseconds = 800;
        const characterSelectionMilliseconds = 40;
        const delayMilliseconds = 250;
        const characters = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*#@/*!%&^"];
        
        const randomArrayElement = arr => {
          return arr[arr.length * Math.random() | 0];
        };
        
        links.forEach(element => {
          element.addEventListener("mouseenter", e => {
            const element = e.target;
            scrambleText(element);
            e.preventDefault();
          });
        });
        
        function scrambleText(element).........完整代码请登录后点击上方下载按钮下载查看

网友评论0