html闪电效果,html闪电绘制文字动画特效源码 内容随便改

本文分享了一段HTML代码,可以实现闪电效果的文字输入动画。当用户在输入框输入文字或点击页面时,会触发炫酷的闪电效果。代码包括了闪电形状的绘制和粒子效果的生成,适用于创建吸引人的交互式网页特效。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

7f38d0b59fe56ea47e9470d27f73189b.gif

7f38d0b59fe56ea47e9470d27f73189b.gif

代码附上html>

html5 canvas闪电绘制文字动画特效

.page-thunder-to-text {

position: relative;

overflow: hidden;

}

.page-thunder-to-text canvas {

display: block;

}

.page-thunder-to-text input {

position: absolute;

bottom: 50px;

left: 0;

right: 0;

display: block;

outline: none;

background-color: rgba(38, 50, 56, 0.2);

color: #ffffff;

border: none;

width: 50%;

min-width: 500px;

max-width: 100%;

margin: auto;

height: 60px;

line-height: 60px;

font-size: 40px;

padding: 0 20px;

}

.page-thunder-to-text input:hover, .page-thunder-to-text input:focus {

border: 1px solid rgba(38, 50, 56, 0.6);

}

.page-thunder-to-text input::-webkit-input-placeholder {

color: rgba(255, 255, 255, 0.1);

}

let canvas, ctx, w, h, thunder, text, particles, input;

function Thunder(options) {

options = options || {};

this.lifespan = options.lifespan || Math.round(Math.random() * 10 + 10);

this.maxlife = this.lifespan;

this.color = options.color || '#fefefe';

this.glow = options.glow || '#2323fe';

this.x = options.x || Math.random() * w;

this.y = options.y || Math.random() * h;

this.width = options.width || 2;

this.direct = options.direct || Math.random() * Math.PI * 2;

this.max = options.max || Math.round(Math.random() * 10 + 20);

this.segments = [...new Array(this.max)].map(() => {

return {

direct: this.direct + (Math.PI * Math.random() * 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值