HTML炫酷页面代码分享

目录

代码雨

鼠标点击爱心特效

 鼠标跟随特效


实例演示:

        代码雨

        鼠标点击爱心特效

        鼠标跟随特效

 


代码雨

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Code</title>
    <style>
        body{
            margin: 0;
            overflow: hidden;
        }
    </style>
</head>

<body>
<canvas id="myCanvas"></canvas>
<script>
    const width = document.getElementById("myCanvas").width = screen.availWidth;
    const height = document.getElementById("myCanvas").height = screen.availHeight;
    const ctx = document.getElementById("myCanvas").getContext("2d");
    const arr = Array(Math.ceil(width / 10)).fill(0);
    const str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("");

function rain() {
    ctx.fillStyle = "rgba(0,0,0,0.05)";
    ctx.fillRect(0, 0, width, height);
    ctx.fillStyle = "#0f0";
    arr.forEach(function (value, index) {
        ctx.fillText(str[Math.floor(Math.random() * str.length)], index * 10, value + 10);
        arr[index] = value >= height || value > 8888 * Math.random() ? 0 : value + 10;
    });
}

setInterval(rain, 30);
</script>
</body>
</html>

鼠标点击爱心特效

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
 
<body>
    <!-- 网页鼠标点击特效(爱心) -->
    <script type="text/javascript">
         ! function (e, t, a) {
            function r() {
                for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[
                        e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x +
                    "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e]
                    .scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
                requestAnimationFrame(r)
            }
 
            function n() {
                var t = "function" == typeof e.onclick && e.onclick;
                e.onclick = function (e) {
                    t && t(), o(e)
                }
            }
 
            function o(e) {
                var a = t.createElement("div");
                a.className = "heart", s.push({
                    el: a,
                    x: e.clientX - 20,
                    y: e.clientY - 20,
                    scale: 1,
                    alpha: 1,
                    color: c()
                }), t.body.appendChild(a)
            }
 
            function i(e) {
                var a = t.createElement("style");
                a.type = "text/css";
                try {
                    a.appendChild(t.createTextNode(e))
                } catch (t) {
                    a.styleSheet.cssText = e
                }
                t.getElementsByTagName("head")[0].appendChild(a)
            }
 
            function c() {
                return "rgb(" + ~~(695 * Math.random()) + "," + ~~(395 * Math.random()) + "," + ~~(995 * Math
                    .random()) + ")"
            }
            var s = [];
            e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e
                .mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
                    setTimeout(e, 1e3 / 60)
                }, i(
                    ".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 90%;-webkit-border-radius: 90%;-moz-border-radius: 90%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"
                ), n(), r()
        }(window, document);
    </script>
</body>
 
</html>

 鼠标跟随特效

<!DOCTYPE html>
<html lang="en">
 
<head>
    
</head>
 
<body>
    <span class="js-cursor-container"></span>
    <script>
        (function fairyDustCursor() {
 
            var possibleColors = ["#D61C59", "#E7D84B", "#1B8798"]
            var width = window.innerWidth;
            var height = window.innerHeight;
            var cursor = { x: width / 2, y: width / 2 };
            var particles = [];
 
            function init() {
                bindEvents();
                loop();
            }
 
           
            function bindEvents() {
                document.addEventListener('mousemove', onMouseMove);
                window.addEventListener('resize', onWindowResize);
            }
 
            function onWindowResize(e) {
                width = window.innerWidth;
                height = window.innerHeight;
            }
 
            function onMouseMove(e) {
                cursor.x = e.clientX;
                cursor.y = e.clientY;
 
                addParticle(cursor.x, cursor.y, possibleColors[Math.floor(Math.random() * possibleColors.length)]);
            }
 
            function addParticle(x, y, color) {
                var particle = new Particle();
                particle.init(x, y, color);
                particles.push(particle);
            }
 
            function updateParticles() {
 
                
                for (var i = 0; i < particles.length; i++) {
                    particles[i].update();
                }
 
               
                for (var i = particles.length - 1; i >= 0; i--) {
                    if (particles[i].lifeSpan < 0) {
                        particles[i].die();
                        particles.splice(i, 1);
                    }
                }
 
            }
 
            function loop() {
                requestAnimationFrame(loop);
                updateParticles();
            }
 
          
 
            function Particle() {
 
                this.character = "*";
                this.lifeSpan = 120; //ms
                this.initialStyles = {
                    "position": "fixed",
                    "display": "inline-block",
                    "top": "0px",
                    "left": "0px",
                    "pointerEvents": "none",
                    "touch-action": "none",
                    "z-index": "10000000",
                    "fontSize": "25px",
                    "will-change": "transform"
                };
 
              
                this.init = function (x, y, color) {
 
                    this.velocity = {
                        x: (Math.random() < 0.5 ? -1 : 1) * (Math.random() / 2),
                        y: 1
                    };
 
                    this.position = { x: x + 10, y: y + 10 };
                    this.initialStyles.color = color;
 
                    this.element = document.createElement('span');
                    this.element.innerHTML = this.character;
                    applyProperties(this.element, this.initialStyles);
                    this.update();
 
                    document.querySelector('.js-cursor-container').appendChild(this.element);
                };
 
                this.update = function () {
                    this.position.x += this.velocity.x;
                    this.position.y += this.velocity.y;
                    this.lifeSpan--;
 
                    this.element.style.transform = "translate3d(" + this.position.x + "px," + this.position.y + "px, 0) scale(" + (this.lifeSpan / 120) + ")";
                }
 
                this.die = function () {
                    this.element.parentNode.removeChild(this.element);
                }
 
            }
 
           
            function applyProperties(target, properties) {
                for (var key in properties) {
                    target.style[key] = properties[key];
                }
            }
 
            if (!('ontouchstart' in window || navigator.msMaxTouchPoints)) init();
        })();    
    </script>
</body>
 
</html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/345788.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

shell脚本-条件测试、

一.条件测试 1.&#xff08; &#xff09; 和 { } &#xff08;&#xff09;会进/data ,开启子shell { } 直接切过去了&#xff0c;不开子shell 小案例&#xff1a; 2. test 命令 测试特定的表达式是否成立&#xff0c;当条件成立&#xff0c;测试语句的返回值为0&#xff…

2024问题汇总

2024问题汇总 Linux1.df-h / df -i 命令2.为多网卡Linux云服务器配置策略路由 Windows1.快速进入控制面板 网络连接指令 Linux 1.df-h / df -i 命令 df -h / df -i 都表示查看磁盘空间使用信息 如果遇到磁盘快满的情况&#xff0c;用这两个命令区别如下 df -h 是去删除比较大 …

Web--HTML基础

文章目录 安装环境HTMLhtml框架html基础标签语义标签html特殊符号 安装环境 安装vscode后 安装插件 可以先不写后台直接将前度界面展示出来 自动补全tag&#xff0c;同时修改tag时自动改另一半 在设置里将保存自动格式化的选项勾上 创建一个index.htm文件&#xff0c;这个…

2024.1.23(347.前k个高频元素)

2024.1.23(347.前k个高频元素) 思路 这道题目主要涉及到如下三块内容&#xff1a; 1.要统计元素出现频率 2.对频率排序 3.找出前K个高频元素 首先统计元素出现的频率&#xff0c;这一类的问题可以使用map来进行统计。 然后是对频率进行排序&#xff0c;这里我们可以使用一种…

【Bugku-web】HEADache

1.打开练习场景 2.在kali中输入以下命令&#xff1a;curl http://82.157.146.43:14340/ -H "Wanna-something: can-i-have- a-flag-please" 3.回车后&#xff0c;得到flag值&#xff0c;提交

搭建k8s集群实战(一)系统设置

1、架构及服务 Kubernetes作为容器集群系统&#xff0c;通过健康检查重启策略实现了Pod故障自我修复能力&#xff0c;通过调度算法实现将Pod分布式部署&#xff0c;并保持预期副本数&#xff0c;根据Node失效状态自动在其他Node拉起Pod&#xff0c;实现了应用层的高可用性。 …

消息中间件之RocketMQ(二)

RocketMQ支持的消息类型 了解之前&#xff0c;首先要熟悉RocketMQ中的组件架构设计 1.顺序消息 将同一个订单(即具有相同的orderId)的消息按状态先后顺序消费的&#xff0c;所以消息生产者调用send方法发送时需要传入MessageQueueSelector接口的,实现类&#xff0c;将order…

Sulfo Cy3 hydrazide,磺化-Cy3-酰肼,可用于与生物分子的羰基衍生物偶联

您好&#xff0c;欢迎来到新研之家 文章关键词&#xff1a;Sulfo-Cyanine3-hydrazide&#xff0c;Sulfo Cy3 hydrazide&#xff0c;Sulfo Cyanine3 HZ&#xff0c;磺化 Cy3 酰肼&#xff0c;磺化-Cy3-酰肼 一、基本信息 产品简介&#xff1a;Sulfo-Cyanine3-hydrazide能够与…

C#使用DateTime.Now.AddDays方法获取任一天的信息

目录 一、使用DateTime对象的AddDays方法获取任一天信息方法 二、举例说明获取昨天的信息 三、涉及到的知识点 1. MessageBox.Show(&#xff09;中信息分行的办法 使用DateTime.Now属性可以得到当前的日期信息&#xff0c;此时调用ToString方法&#xff0c;并在该方法中添加…

封装 element el-date-picker时间选择区间

基于el-date-picker 处理满足项目需求。&#xff08;&#xff1a;最多选择7天&#xff09; 效果&#xff1a; 1 大于当前时间的以后日期禁选。2 选中时间的前后七天可选 &#xff08;最多可查询7天数据&#xff09;3 <template><section class"warning-contai…

k8s---helm

Helm是什么&#xff1f; 在没有helm之前。部署一个服务&#xff0c;需要deployment、service、ingress、挂在卷等等相关配置都需要人工来配置。 helm的作用就是通过打包的方式&#xff0c;把需要人工编写的配置集成在一起。是一键式的部署服务。类似于yum功能。 由官方提供的…

JDK 版本切换工具 JEnv

1. 下载 JEnv 包 下载地址&#xff1a; JEnv-for-Windows 下载 JEnv.zip 然后解压缩&#xff0c;放到一个目录下&#xff0c;我这里放到了目录&#xff1a;D:\Program Files\JEnv 2. 将 JEnv 添加到环境变量 首先先在自己的电脑上去下载 JAVA 的各个版本&#xff0c;我这里…

webassembly003 whisper.cpp的python绑定实现+Cython+Setuptools

python绑定项目 官方未提供python的封装绑定&#xff0c;直接调用执行文件 https://github.com/stlukey/whispercpp.py提供了源码和Cpython结合的绑定 https://github.com/zhujun1980/whispercpp_py提供了ctype方式的绑定&#xff0c;需要先make libwhisper.so Pybind11 bi…

全网盘点内网穿透端口映射工具大整理,近百种端口映射工具使用方法介绍以及特性和优缺点分析

全网盘点内网穿透端口映射工具大整理&#xff0c;近百种端口映射工具使用方法介绍以及特性和优缺点分析。 “端口映射”通俗来说就是将外网主机的IP地址端口映射到内网中一台机器&#xff0c;提供相应的服务。内网相通&#xff0c;电因特网对外开放服务或者接收大数据&#xff…

【Leetcode】410. 分割数组的最大值

文章目录 题目思路1.max_element2.partial_sum3.upper_bound4.distance 代码运行结果 题目 题目链接 给定一个非负整数数组 nums 和一个整数 k &#xff0c;你需要将这个数组分成 k 个非空的连续子数组。 设计一个算法使得这 k 个子数组各自和的最大值最小。 示例1&#xff1…

JS中splice方法的用法总结

1. 概述 JavaScript中的splice()方法是用于增加、删除或替换数组中的元素。这个方法可以实现数组的细粒度操作,非常灵活和强大。 2. 语法 splice()方法的语法如下所示: start:必需,表示开始删除或插入的索引位置。如果为负数,则从数组的末尾开始计算。deleteCount:可选…

全球地面实测凋落物(Litterfall) 数据集

1. 研究背景 [3] 主要结论&#xff1a;作者结合litterfall数据和SIF/EVI数据&#xff0c;揭示了物候的规律 1. 对于光照和降水异步的地区&#xff08;Rclimate<0&#xff0c;背景是红色&#xff09; 紫色点&#xff08;赤道地区&#xff09;&#xff1a;落叶和长叶都在…

windows和linux下SHA1,MD5,SHA256校验办法

今天更新android studio到Android Studio Hedgehog | 2023.1.1时&#xff0c;发现提示本机安装的git版本太老&#xff0c;于是从git官网下载最新的git。 git下载地址&#xff1a; https://git-scm.com/ 从官网点击下载最新windows版本会跳转到github仓库来下载发布的git&…

一、Lamdba 表达式与函数式接口

一、Lamdba 表达式与函数式接口 1.1 Lamdba 表达式与函数式接口 1.1.1 Lambda 表达式概述 Lambda 表达式是 Java 8 引入的一个新特性Lambda 表达式可以被视为匿名函数允许在需要函数的地方以更简洁的方法定义功能Lambda 表达式可以完成简洁的函数定义Stream API 中大量使用了…

Optional的使用(代替if判断是否为空)

Optional 前言 我的使用 package yimeng;import com.ruoyi.RuoYiApplication; import com.ruoyi.common.core.domain.entity.SysUser; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import java.util.*;SpringBootTes…
最新文章