当前位置:   article > 正文

甜甜甜!HTML5 快速实现一颗告白爱心树!| 原力计划

爱情树的html代码

作者 | Himit_ZH

责编 | 伍杏玲

出品 | CSDN博客

利用HTML5、CSS、JS实现爱心树以及纪念日期的功能,网页有播放音乐功能 以及打字倾诉感情的画面,非常适合送给女朋友。

具体的HTML代码

具体只要修改代码里面的男某某和女某某 文字段也可自行修改,还有代码下半部分的JS代码需要修改一下起始日期 注意月份为0~11月 也就是月份需要减一。

当然只有一部分HTML和JS代码不够运行的,文章最下面还附加了完整代码的下载地址

  1. <!DOCTYPE html>
  2. <html xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3. <title>男某某与女某某日期纪念功能</title>
  4.         <link type="text/css" rel="stylesheet" href="./index_files/default.css">
  5. <script type="text/javascript" src="./index_files/jquery.min.js"></script>
  6. <script type="text/javascript" src="./index_files/jscex.min.js"></script>
  7. <script type="text/javascript" src="./index_files/jscex-parser.js"></script>
  8. <script type="text/javascript" src="./index_files/jscex-jit.js"></script>
  9. <script type="text/javascript" src="./index_files/jscex-builderbase.min.js"></script>
  10. <script type="text/javascript" src="./index_files/jscex-async.min.js"></script>
  11. <script type="text/javascript" src="./index_files/jscex-async-powerpack.min.js"></script>
  12. <script type="text/javascript" src="./index_files/functions.js" charset="utf-8"></script>
  13. <script type="text/javascript" src="./index_files/love.js" charset="utf-8"></script>
  14.     <style type="text/css">
  15. <!--
  16. .STYLE1 {color: #666666}
  17. -->
  18.         </style>
  19. </head>
  20.     <body>
  21.         <div id="main">
  22.             <div id="error">本页面采用HTML5编辑,目前您的浏览器无法显示,请换成谷歌(<a href="http://www.google.cn/chrome/intl/zh-CN/landing_chrome.html?hl=zh-CN&brand=CHMI">Chrome</a>)或者火狐(<a href="http://firefox.com.cn/download/">Firefox</a>)浏览器,或者其他游览器的最新版本。</div>
  23.             <div id="wrap">
  24.                 <div id="text">
  25.         <div id="code">
  26.         <span class="say">* 致女某某: *</span><br>
  27. <span class="say"> </span><br>
  28.         <span class="say">· 女某某,情人节快乐!</span><br>
  29. <span class="say"> </span><br>
  30.                         <span class="say">· 不经意相识, 或许是缘分,或许是注定的。</span><br>
  31. <span class="say"> </span><br>
  32.         <span class="say">· 虽然......,但依......!</span><br>
  33. <span class="say"> </span><br>
  34.         <span class="say">· 虽然......,但......!</span><br>
  35. <span class="say"> </span><br>
  36.         <span class="say">· 虽然......,但......!</span><br>
  37. <span class="say"> </span><br>
  38.         <span class="say">· 虽然......</span><br>
  39. <span class="say"> </span><br>
  40.         <span class="say">· 无论如何,只要你我依旧喜欢对方,我会一直陪着你。</span><br>
  41.                         <span class="say"> </span><br>
  42.                         <span class="say">· You are my only girlfriend.</span><br>
  43. <span class="say"> </span><br>
  44. <span class="say">· I love you,×××!</span><br>
  45. <span class="say"> </span><br>
  46.                         <span class="say"><span class="space"></span>--@author 男某某--</span>
  47.         </div>
  48.                 </div>
  49.                 <div id="clock-box">
  50.                     <span class="STYLE1">现在是</span>男某某 <span class="STYLE1style="colorred">❤</span> 女某某<span class="STYLE1style="colorred">相恋</span>
  51.                   <div id="clock"></div>
  52.               </div>
  53.                 <canvas id="canvaswidth="1100" height="680"></canvas>
  54.             </div>
  55.         </div>
  56.     <script>
  57.     </script>
  58.     <script>
  59.     (function(){
  60.         var canvas = $('#canvas');
  61.         if (!canvas[0].getContext) {
  62.             $("#error").show();
  63.             return false;
  64.         }
  65.         var width = canvas.width();
  66.         var height = canvas.height();
  67.         canvas.attr("width", width);
  68.         canvas.attr("height", height);
  69.         var opts = {
  70.             seed: {
  71.                 x: width / 2 - 20,
  72.                 color: "rgb(190, 26, 37)",
  73.                 scale: 2
  74.             },
  75.             branch: [
  76.                 [53568057025050020030100, [
  77.                     [54050045541734040013100, [
  78.                         [450435434430394395240]
  79.                     ]],
  80.                     [55044560035668034512100, [
  81.                         [578400648409661426380]
  82.                     ]],
  83.                     [539281537248534217340],
  84.                     [546397413247328244980, [
  85.                         [427286383253371205240],
  86.                         [498345435315395330460]
  87.                     ]],
  88.                     [5463576082526782216100, [
  89.                         [590293646277648271280]
  90.                     ]]
  91.                 ]] 
  92.             ],
  93.             bloom: {
  94.                 num: 700,
  95.                 width: 1080,
  96.                 height: 650,
  97.             },
  98.             footer: {
  99.                 width: 1200,
  100.                 height: 5,
  101.                 speed: 10,
  102.             }
  103.         }
  104.         var tree = new Tree(canvas[0], width, height, opts);
  105.         var seed = tree.seed;
  106.         var foot = tree.footer;
  107.         var hold = 1;
  108.         canvas.click(function(e) {
  109.             var offset = canvas.offset(), x, y;
  110.             x = e.pageX - offset.left;
  111.             y = e.pageY - offset.top;
  112.             if (seed.hover(x, y)) {
  113.                 hold = 0
  114.                 canvas.unbind("click");
  115.                 canvas.unbind("mousemove");
  116.                 canvas.removeClass('hand');
  117.             }
  118.         }).mousemove(function(e){
  119.             var offset = canvas.offset(), x, y;
  120.             x = e.pageX - offset.left;
  121.             y = e.pageY - offset.top;
  122.             canvas.toggleClass('hand', seed.hover(x, y));
  123.         });
  124.         var seedAnimate = eval(Jscex.compile("async", function () {
  125.             seed.draw();
  126.             while (hold) {
  127.                 $await(Jscex.Async.sleep(10));
  128.             }
  129.             while (seed.canScale()) {
  130.                 seed.scale(0.95);
  131.                 $await(Jscex.Async.sleep(10));
  132.             }
  133.             while (seed.canMove()) {
  134.                 seed.move(02);
  135.                 foot.draw();
  136.                 $await(Jscex.Async.sleep(10));
  137.             }
  138.         }));
  139.         var growAnimate = eval(Jscex.compile("async", function () {
  140.             do {
  141.             tree.grow();
  142.                 $await(Jscex.Async.sleep(10));
  143.             } while (tree.canGrow());
  144.         }));
  145.         var flowAnimate = eval(Jscex.compile("async", function () {
  146.             do {
  147.             tree.flower(2);
  148.                 $await(Jscex.Async.sleep(10));
  149.             } while (tree.canFlower());
  150.         }));
  151.         var moveAnimate = eval(Jscex.compile("async", function () {
  152.             tree.snapshot("p1"2400610680);
  153.             while (tree.move("p1"5000)) {
  154.                 foot.draw();
  155.                 $await(Jscex.Async.sleep(10));
  156.             }
  157.             foot.draw();
  158.             tree.snapshot("p2"5000610680);
  159.             canvas.parent().css("background""url(" + tree.toDataURL('image/png') + ")");
  160.             canvas.css("background""#ffe");
  161.             $await(Jscex.Async.sleep(300));
  162.             canvas.css("background""none");
  163.         }));
  164.         var jumpAnimate = eval(Jscex.compile("async", function () {
  165.             var ctx = tree.ctx;
  166.             while (true) {
  167.                 tree.ctx.clearRect(00, width, height);
  168.                 tree.jump();
  169.                 foot.draw();
  170.                 $await(Jscex.Async.sleep(25));
  171.             }
  172.         }));
  173.        //下面修改起始日期
  174.         var textAnimate = eval(Jscex.compile("async", function () {
  175.     var together = new Date();
  176.     together.setFullYear(202012); //时间年月日 月份0~11
  177.     together.setHours(22);    //小时
  178.     together.setMinutes(22);    //分钟
  179.     together.setSeconds(2);    //秒前一位
  180.     together.setMilliseconds(2);    //秒第二位
  181.     $("#code").show().typewriter();
  182.             $("#clock-box").fadeIn(500);
  183.             while (true) {
  184.                 timeElapse(together);
  185.                 $await(Jscex.Async.sleep(1000));
  186.             }
  187.         }));
  188.         var runAsync = eval(Jscex.compile("async", function () {
  189.             $await(seedAnimate());
  190.             $await(growAnimate());
  191.             $await(flowAnimate());
  192.             $await(moveAnimate());
  193.             textAnimate().start();
  194.             $await(jumpAnimate());
  195.         }));
  196.         runAsync().start();
  197.     })();
  198.     </script>
  199.     <iframe src = "./给你们.mp3" allow = "autoplay" hidden /> //自己修改音乐位置
  200. </body>
  201. </html>

画面演示

①点击网页中心的爱心,刚进入网页会自动播放音乐

②会慢慢生成爱心树,速度挺快的

③然后会平移爱心树到最右边,准备生成文章

④会慢慢生成所要说的话 日期设定是2020.02.02 22:22:22

⑤最后的样子

代码:

https://pan.baidu.com/s/1DE2l4fkNdnZUxxme4HS6vw,提取码: i69r

原文链接:https://blog.csdn.net/weixin_43853097/article/details/104240158

技术战“疫”,贾扬清、李飞飞要给程序员直播讲AI技术!

2月18日、2月20日,阿里云CIO学院攻“疫”技术课程正式开启。您将获得与达摩院数据库首席科学家 、阿里巴巴集团副总裁、ACM 杰出科学家李飞飞,Caffe之父、ONNX创始人、阿里巴巴集团副总裁贾扬清,阿里巴巴集团副总裁、阿里 CIO 学院院长胡臣杰等顶级技术专家直播互动的机会。

热 文 推 荐

“删库跑路”这件事情真的发生了 ,还是技术总监干的!

掌握此文,面试再也不怕红黑树!

10 万阿里人都爱用的网红工具,语雀如何“用保护钱包的技术在保护文档安全”?

大神如何一招完美解决Hadoop集群无法正常关闭的问题!| 博文精选

一文读懂拜占庭将军问题

超赞的PyTorch资源大列表,GitHub标星9k+,中文版也上线了

你点的每个“在看”,我都认真当成了喜欢

点击阅读原文,即刻报名以上直播活动!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/120662
推荐阅读
相关标签
  

闽ICP备14008679号