Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

五彩圣诞美化 - 添加飘雪特效

[复制链接]
heikafeijp 发表于 2007-12-9 22:35:43 | 显示全部楼层 |阅读模式
首先感谢五彩圣诞的作者给我们提供了如此漂亮的风格。
自己在网上找了一段特效代码,成功实现了飘雪特效,发现有人在找,就在此分享给大家。

添加方法,请按下面的步聚:

1.打开 tmplates/Christmas/header.htm

找到:<body onkeydown="if(event.keyCode==27) return false;">

在下面加入:
  1. <!--//雪花特效开始//-->
  2. <SCRIPT LANGUAGE="JavaScript1.2">
  3. <!--
  4. var no = 18;
  5. var speed = 50;
  6. var heart = "snow.gif";<!--//此图片是飘动的雪花图片,可自定,相对路径和绝对路径都可//-->
  7. var flag;
  8. var ns4up = (document.layers) ? 1 : 0;
  9. var ie4up = (document.all) ? 1 : 0;

  10. var dx, xp, yp;
  11. var am, stx, sty;
  12. var i, doc_width = 800, doc_height = 600;
  13. if (ns4up) {
  14. doc_width = self.innerWidth;
  15. doc_height = self.innerHeight;
  16. } else if (ie4up) {
  17. doc_width = document.body.clientWidth;
  18. doc_height = document.body.clientHeight;
  19. }
  20. dx = new Array();
  21. xp = new Array();
  22. yp = new Array();
  23. amx = new Array();
  24. amy = new Array();
  25. stx = new Array();
  26. sty = new Array();
  27. flag = new Array();
  28. for (i = 0; i < no; ++ i) {
  29. dx[i] = 0; // set coordinate variables
  30. xp[i] = Math.random()*(doc_width-30)+10;
  31. yp[i] = Math.random()*doc_height;
  32. amy[i] = 12+ Math.random()*20;
  33. amx[i] = 10+ Math.random()*40;
  34. stx[i] = 0.02 + Math.random()/10;
  35. sty[i] = 0.7 + Math.random();
  36. flag[i] = (Math.random()>0.5)?1:0;
  37. if (ns4up) { // set layers
  38. if (i == 0) {
  39. document.write("<layer name="dot"+ i +"" left="15" ");
  40. document.write("top="15" visibility="show"><img src="");
  41. document.write(heart+ "" border="0"></layer>");
  42. } else {
  43. document.write("<layer name="dot"+ i +"" left="15" ");
  44. document.write("top="15" visibility="show"><img src="");
  45. document.write(heart+ "" border="0"></layer>");
  46. }
  47. } else
  48. if (ie4up) {
  49. if (i == 0) {
  50. document.write("<div id="dot"+ i +"" style="POSITION: ");
  51. document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
  52. document.write("visible; TOP: 15px; LEFT: 15px;"><img src="");
  53. document.write(heart+ "" border="0"></div>");
  54. } else {
  55. document.write("<div id="dot"+ i +"" style="POSITION: ");
  56. document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
  57. document.write("visible; TOP: 15px; LEFT: 15px;"><img src="");
  58. document.write(heart+ "" border="0"></div>");
  59. }
  60. }
  61. }

  62. function helpor_net() {
  63. for (i = 0; i < no; ++ i) {
  64. if (yp[i] > doc_height-50) {
  65. xp[i] = 10+ Math.random()*(doc_width-amx[i]-30);
  66. yp[i] = 0;
  67. flag[i]=(Math.random()<0.5)?1:0;
  68. stx[i] = 0.02 + Math.random()/10;
  69. sty[i] = 0.7 + Math.random();
  70. doc_width = self.innerWidth;
  71. doc_height = self.innerHeight;
  72. }
  73. if (flag[i])
  74. dx[i] += stx[i];
  75. else
  76. dx[i] -= stx[i];
  77. if (Math.abs(dx[i]) > Math.PI) {
  78. yp[i]+=Math.abs(amy[i]*dx[i]);
  79. xp[i]+=amx[i]*dx[i];
  80. dx[i]=0;
  81. flag[i]=!flag[i];
  82. }
  83. document.layers["dot"+i].top = yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i]));
  84. document.layers["dot"+i].left = xp[i] + amx[i]*dx[i];

  85. }
  86. setTimeout("helpor_net()", speed);
  87. }

  88. function www_helpor_net() {
  89. for (i = 0; i < no; ++ i) {
  90. if (yp[i] > doc_height-50) {
  91. xp[i] = 10+ Math.random()*(doc_width-amx[i]-30);
  92. yp[i] = 0;
  93. stx[i] = 0.02 + Math.random()/10;
  94. sty[i] = 0.7 + Math.random();
  95. flag[i]=(Math.random()<0.5)?1:0;
  96. doc_width = document.body.clientWidth;
  97. doc_height = document.body.clientHeight;
  98. }
  99. if (flag[i])
  100. dx[i] += stx[i];
  101. else
  102. dx[i] -= stx[i];
  103. if (Math.abs(dx[i]) > Math.PI) {
  104. yp[i]+=Math.abs(amy[i]*dx[i]);
  105. xp[i]+=amx[i]*dx[i];
  106. dx[i]=0;
  107. flag[i]=!flag[i];
  108. }

  109. document.all["dot"+i].style.pixelTop = yp[i] + amy[i]*(Math.abs(Math.sin(dx[i])+dx[i]));
  110. document.all["dot"+i].style.pixelLeft = xp[i] + amx[i]*dx[i];
  111. }
  112. setTimeout("www_helpor_net()", speed);
  113. }

  114. if (ns4up) {
  115. helpor_net();
  116. } else if (ie4up) {
  117. www_helpor_net();
  118. }
  119. //-->
  120. </script>
  121. <!--//雪花特效结束//-->
复制代码
2.上传雪花图片(我自己做的,有一点闪光效果)



上传到 images目录中(可以是任意目录,不过修改代码的时候要注意路径的正确连接)

3.更新缓存即可

效果演示:

http://bbs.yakecn.net

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

评分

1

查看全部评分

雾潮 发表于 2007-12-9 22:41:20 | 显示全部楼层
不错的,谢谢朋友。。。
回复

使用道具 举报

七步断肠1 发表于 2007-12-9 22:45:10 | 显示全部楼层
不错不错
回复

使用道具 举报

四季歌 发表于 2007-12-9 23:39:35 | 显示全部楼层
回复

使用道具 举报

38274798 发表于 2007-12-10 02:15:42 | 显示全部楼层
安装成功 谢谢了
www.sf138.net
回复

使用道具 举报

疯伟 发表于 2007-12-10 03:07:31 | 显示全部楼层
支持..
待安装


http://www.admin186.com
回复

使用道具 举报

yah007 发表于 2007-12-10 04:26:26 | 显示全部楼层
ff 下不能显示
回复

使用道具 举报

zywsderg 发表于 2007-12-10 04:27:27 | 显示全部楼层
原帖由 heikafsmjp 于 2007-12-9 22:35 发表
首先感谢五彩圣诞的作者给我们提供了如此漂亮的风格。
自己在网上找了一段特效代码,成功实现了飘雪特效,发现有人在找,就在此分享给大家。

添加方法,请按下面的步聚:

1.打开 tmplates/Christmas/header.h ...


不错,谢谢
回复

使用道具 举报

sn天堂使 发表于 2007-12-10 08:16:03 | 显示全部楼层
原帖由 yah007 于 2007-12-10 04:26 发表
ff 下不能显示

支持一个`
FF下不能显示也不是什么奇怪的事`过往有很多JS特效FF都不支持的`

[ 本帖最后由 sn天堂使 于 2007-12-10 08:24 编辑 ]
回复

使用道具 举报

dyxgxm 发表于 2007-12-10 08:21:47 | 显示全部楼层
这个雪花太闪了,我贡献一个吧,
<EMBED style="LEFT: 183px; POSITION: absolute; TOP: -70px" align=right src=http://imgfree.21cn.com/free/flash/68.swf width=698 height=303 type=application/x-shockwave-flash wmode="transparent" quality="high"></EMBED>
加入到header.htm的任意位置。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-6-2 14:06 , Processed in 0.225825 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表