animate css3 应用的借鉴,一个同事写的JS

	  $("#banner").height($(window).height()-125);
	   $(window).resize(function(){ 
	   $("#banner").height($(window).height()-125);
     });   
	//首页幻灯
	$(".indeximgs:first").show();
	
	var i=0;
	$(".leftbut").click(function(){
			$(".indeximgs").hide();
			i=i-1;
                         if (i==-1) {i=5}
			$(".indeximgs:eq("+i+")").fadeIn(1000);
		});
		
	$(".rightbut").click(function(){	
			$(".indeximgs").hide();
                        i=i+1;
                          if (i==6) {i=0}	
			$(".indeximgs:eq("+i+")").fadeIn(1000);                      
		});
	//logo动画效果
	$("#logo").hover(
	function(){
			 $("#logo img").attr('src','img/logo1.jpg');
	         $("#logo img").addClass('animated flipInY');
		},
	function(){
		 $("#logo img").removeClass('flipInY');
		 $("#logo img").addClass('animated flipInX');
		  $("#logo img").attr('src','img/logo.jpg');
	});

 	 //导航动画效果
	 $("#guild ul li").hover(
	 		function(){	$(this).addClass('animated pulse');},
			function(){$(this).removeClass('pulse');}
	 );
	//banner出现时一次动画
		$("#banner").addClass('animated fadeInDown');
	//搜索事件
		$("#sbut").hover(function(){$("#search").show();$("#search").removeClass('slideOutLeft'); $("#search").addClass('animated fadeInLeftBig');});
		$("#closesearch").click(function(){setTimeout(function(){$("#search").hide();},1000);$("#search").addClass('animated slideOutLeft');$("#search").removeClass('fadeInLeftBig');});
	//优化显示
	$("#indexperson").css("visibility","hidden");
	$("#huandeng").css("visibility","hidden");
	$("#foot").css("visibility","hidden");

	 $(document).ready(function(){
		 $(window).bind("scroll", function(event){
			 	if ($(window).scrollTop()>303 && $(window).scrollTop()<407) { 
				$("#indexperson").css("visibility","visible");
				$("#indexperson").addClass('animated fadeInUp');
				//setTimeout(function(){$("#indexperson").removeClass('fadeInUp');},2000);
				}
			 	if ($(window).scrollTop()>515 && $(window).scrollTop()<930) { 
				$("#huandeng").css("visibility","visible");
				$("#huandeng").addClass('animated fadeInUp');
				//setTimeout(function(){$("#huandeng").removeClass('fadeInUp');},2000);
				}
				if ($(window).scrollTop()>1300 && $(window).scrollTop()<1500) { 
				$("#foot,#copyright").css("visibility","visible");
				$("#foot,#copyright").addClass('animated fadeInUp');
				//setTimeout(function(){$("#foot").removeClass('rotateInDownLeft');},2000);
				}
		 });
		 
	 
		});
    

  同事做的网站sanbf.com的效果应用。。

 

转载于:https://www.cnblogs.com/qfly/p/4654648.html

<think>好的,我现在需要帮助用户创建一个使用HTML、CSS和JavaScript编3D烟花效果的小程序,用于女神节祝福。用户希望得到一个代码示例。首先,我要回顾用户提供的引用内容,看看有没有相关的例子或者可以借鉴的部分。 根据用户提供的引用,特别是引用[3]、[4]、[5]都提到了使用HTML、CSS和JavaScript制作节日贺卡,其中引用[5]提到了烟花特效的实现。用户可能希望类似的效果,但需要调整主题为女神节,可能包括文字祝福、3D烟花动画以及交互元素。 接下来,我需要考虑如何构建这个程序的结构。通常,这样的动画会用到HTML结构来放置元素,CSS进行样式设计和布局,JavaScript处理动画逻辑和用户交互。对于3D烟花效果,可能需要使用Canvas元素来绘制图形,或者利用CSS33D变换和动画。不过,考虑到性能,Canvas可能更适合处理大量粒子效果,如烟花爆炸时的粒子。 另外,用户可能需要点击触发烟花效果,这需要JavaScript的事件监听。同时,页面上应该有一些文字祝福,比如“女神节快乐”等,这些可以用HTML和CSS来设计样式,并添加动画效果。 现在,我需要整合这些元素。首先,HTML部分需要一个Canvas元素作为烟花绘制区域,以及包含祝福文字的div。CSS需要设置背景、文字样式和动画。JavaScript部分需要处理烟花的生成、动画和交互。 需要注意的是,引用中的代码可能不完整或需要调整。例如,引用[5]提到点击鼠标触发烟花,这可能需要在JavaScript中添加mousedown或click事件监听器,并在回调函数中生成烟花实例。烟花的爆炸效果可以通过创建粒子对象,每个粒子具有位置、速度、颜色等属性,并在每一帧更新它们的位置,然后重新绘制。 此外,颜色搭配和视觉效果要符合女神节的氛围,可能使用粉色、紫色等柔和的色调,烟花粒子可以有渐变效果。文字部分可能需要添加CSS动画,比如浮动效果或渐显效果,以增强视觉效果。 最后,测试代码的兼容性和性能,确保动画流畅,没有明显的卡顿。可能需要优化粒子数量或绘制方式,比如使用requestAnimationFrame来优化动画循环。 总结步骤: 1. 创建HTML结构,包含Canvas和祝福文字。 2. 使用CSS设置背景、文字样式和动画。 3. 使用JavaScript处理Canvas绘制、烟花粒子的物理模拟和用户交互。 4. 调整参数(如粒子数量、颜色、速度)以达到理想的视觉效果。 5. 测试和优化代码,确保在不同浏览器上运行良好。</think>以下是用HTML+CSS+JavaScript实现3D烟花女神节贺卡的代码示例: ```html <!DOCTYPE html> <html> <head> <title>女神节3D烟花贺卡</title> <style> body { margin: 0; overflow: hidden; background: #000; font-family: &#39;Microsoft YaHei&#39;; } #canvas { position: fixed; top: 0; left: 0; } .greeting { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #ff69b4; text-align: center; z-index: 100; text-shadow: 0 0 10px #ff1493; animation: float 3s ease-in-out infinite; } @keyframes float { 0%, 100% { transform: translate(-50%, -50%) translateY(0); } 50% { transform: translate(-50%, -50%) translateY(-20px); } } </style> </head> <body> <canvas id="canvas"></canvas> <div class="greeting"> <h1>🌹 女神节快乐 🌹</h1> <p>愿你的笑容如烟花般绚烂</p> </div> <script> const canvas = document.getElementById(&#39;canvas&#39;); const ctx = canvas.getContext(&#39;2d&#39;); canvas.width = window.innerWidth; canvas.height = window.innerHeight; class Particle { constructor(x, y, color) { this.x = x; this.y = y; this.color = color; this.radius = Math.random() * 2; this.velocity = { x: (Math.random() - 0.5) * 5, y: (Math.random() - 0.5) * 5 }; this.alpha = 1; } draw() { ctx.save(); ctx.globalAlpha = this.alpha; ctx.beginPath(); ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2); ctx.fillStyle = this.color; ctx.fill(); ctx.restore(); } update() { this.x += this.velocity.x; this.y += this.velocity.y; this.alpha -= 0.01; } } const particles = []; const colors = [&#39;#ff69b4&#39;, &#39;#ff1493&#39;, &#39;#ff00ff&#39;, &#39;#ffc0cb&#39;]; function createFirework(x, y) { for (let i = 0; i < 100; i++) { particles.push(new Particle(x, y, colors[Math.floor(Math.random() * colors.length)])); } } function animate() { ctx.fillStyle = &#39;rgba(0, 0, 0, 0.1)&#39;; ctx.fillRect(0, 0, canvas.width, canvas.height); particles.forEach((particle, index) => { if (particle.alpha > 0) { particle.update(); particle.draw(); } else { particles.splice(index, 1); } }); requestAnimationFrame(animate); } canvas.addEventListener(&#39;click&#39;, (e) => { createFirework(e.clientX, e.clientY); }); animate(); </script> </body> </html> ``` 效果说明: 1. 页面背景为黑色,展示3D烟花动画效果[^5] 2. 点击屏幕任意位置触发粉色系烟花绽放效果[^3] 3. 中央显示带有文字阴影的渐变浮动文字[^4] 4. 烟花粒子使用粉色系颜色(粉红/玫红/紫罗兰等)[^2] 5. 支持响应式布局,自动适配屏幕尺寸[^1]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值