current position:Home>HTML + CSS + JavaScript make 520 Tanabata Valentine's Day code (fireworks confession)

HTML + CSS + JavaScript make 520 Tanabata Valentine's Day code (fireworks confession)

2021-08-22 22:54:43 @. code out the future

* Help programmers get their girls html+css+js Fireworks show ( Including music ) You can edit text by yourself

annual /520 Valentine's Day / Valentine's day on Chinese Valentine's day / a birthday present / Confession younger martial sister / Christmas / New year's day and new year's Eve / Programmer's confession , Do you want to surprise your girlfriend or your sister ,html+css+js Write the tiktok effect of fireworks , Cool and charming , Help programmers get their girls , everything is going smoothly , I wish you all have lovers and get married , Enduring as the universe .. I quickly learned , Let's make the romance that belongs to our programmers !

Web Front-end based Canvas The realization of fireworks express effect , Based on the Canvas Understanding of the realization of , There will always be a little surprise , Can be amazing to each other's short time .



* Preface

For programmers ,“ single ” Still the biggest thing in life bug, The point is that you can't debug yet . As the saying goes “ Since ancient times, heroes are lonely ”, But life without a partner is always incomplete . Besides, , From the annual love ( abuse ) people ( Dog ) The festival is not far away .


1. (PC End fireworks ) Effect demonstration

1. Fireworks demonstration address :

2. Including opening remarks + Declare the fireworks demonstration address
 Insert picture description here
 Insert picture description here
 Insert picture description here

1. (H5 Mobile fireworks ) Effect demonstration

 Insert picture description here

* Code file directory

 Insert picture description here

One 、 Code implementation

html ( part )

<!-- * @Author: xf * @Date: 2020-12-21 09:07:44 * @LastEditTime: 2020-12-21 17:27:07 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \firework-master\ Brilliant fireworks \fire.html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <link rel="stylesheet" href="css/style.css">
    <script id="jqbb" src="https://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
    <style> body{
      margin:0;padding:0;overflow: hidden;} .city{
      width:100%;position:fixed;bottom: 0px;z-index: 100;} .city img{
      width: 100%;} audio{
       opacity: 0; } </style>
    <title>
         Cool fireworks show 
    </title>
    <!--  Pop up style  -->
    <link href="modal.css" rel="stylesheet"/>

    <style type="text/css"> html, body {
       background-color: black; overflow: hidden; user-select: none; margin: 0; } </style>
</head>
<body onselectstart="return false">
    <div class="star comet"></div>
    <script src="js/index.js"></script>
  
<!-- Dialogue section -->
<div class="share_img"><img src="img/xin.png" alt=""></div>

<div class="page_one">
    <div class="content">
        <div class="text_wrapper">
            <img class="xin" src="img/xin.png" alt="" />
            <div class="text">
                 Cute girl , I love you , Would you like to be my girlfriend? ?
            </div>
        </div>
    </div>
    <div class="btn-groups">
        <div class="heart-btn">
            <div id="yes" class="btn btn-a"><span> willing </span></div>
        </div>
        <div id="no" class="btn btn-b"><span> Unwilling </span></div>
    </div>
</div>
<!-- Fireworks -->
<div class="city">
    <img src="img/city.png" alt="" />
</div>
<img src="img/moon.png" alt="" id="moon" style="visibility: hidden;" />
<div style="display:none">
    <div class="shape">
        520
    </div>
    <div class="shape">
        Custom text here 
    </div>
    <div class="shape">
         A big crowd 
    </div>
    <div class="shape">
         Meeting is fate 
    </div>
    <div class="shape">
         I love you forever 
    </div>
</div>
<!-- The music part -->
<audio autoplay loop id="music">
    <source src="mp3/music.mp3" />
</audio>
<iframe id="iframMusic" allow="autoplay" style="display:none" src="mp3/blank.mp3"></iframe>
<script src="jquery.min.js"></script>
<script src="fire.js"></script>
<script src="talk.js"></script>
</body>
</html>

js ( part )

var canvas = document.getElementById("cas");
var ocas = document.createElement("canvas");
var octx = ocas.getContext("2d");
var ctx = canvas.getContext("2d");
ocas.width = canvas.width = window.innerWidth;
ocas.height = canvas.height = window.innerHeight;
var bigbooms = [];

// window.onload = function() {
    
// initAnimate();
// };

document.getElementById("iframMusic").onload = function(){
    
    var music = document.getElementById("music");
    music.src = 'music.mp3';
    music.oncanplay = function(){
    
        music.play();
    };
};

function initAnimate() {
    
    drawBg();
    lastTime = new Date();
    animate()
}
var lastTime;

function drawMoon() {
    
    var moon = document.getElementById("moon");
    var centerX = canvas.width - 200,
        centerY = 100,
        width = 80;
    if (moon.complete) {
    
        ctx.drawImage(moon, centerX, centerY, width, width)
    } else {
    
        moon.onload = function() {
    
            ctx.drawImage(moon, centerX, centerY, width, width)
        }
    }
    var index = 0;
    for (var i = 0; i < 10; i++) {
    
        ctx.save();
        ctx.beginPath();
        ctx.arc(centerX + width / 2, centerY + width / 2, width / 2 + index, 0, 2 * Math.PI);
        ctx.fillStyle = "rgba(240,219,120,0.005)";
        index += 2;
        ctx.fill();
        ctx.restore()
    }
}
Array.prototype.foreach = function(callback) {
    
    for (var i = 0; i < this.length; i++) {
    
        if (this[i] !== null) {
    
            callback.apply(this[i], [i])
        }
    }
};
var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
    function(callback) {
    
        window.setTimeout(callback, 1000 / 60)
    };
};

css ( part )

/*  willing  */
.btn-a {
    
  background: pink;
}
.btn-b {
    
  background: #c9c9c9;
}
.btn-b:after {
    
  content: "";
  position: absolute;
  display: block;
  width: 60px;
  height: 30px;
  background: #c9c9c9;
  left: 0;
  top: -29px;
  border-top-left-radius: 60px;
  border-top-right-radius: 60px;
}
.container {
    
}
.container .mask {
    
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
}
.container .modal {
    
  width: 50%;
  height: 160px;
  position: absolute;
  top: 55%;
  left: 50%;
  padding: 20px 15px;
  border-radius: 5px;
  /* transform: translate(-50%, -70%); */
  -webkit-transform: translate(-50%, -0%);
  -webkit-transform: translate(-50%, -0%);
  background: #f3f3f3;
}
.container .modal p {
    
  margin-top: 20px;
  margin-bottom: 20px;
  font-size: 16px;
  color: #353535;
  text-align: center;
}
.type_words {
    
  padding: 12px 20px;
}
.page_one {
    
  position: absolute;
  z-index: 10;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -90%);
}
.text {
    
  color: pink;
  font-size: 16px;
}

.xin {
    
  width: 20%;
}

Two 、3D Album clipping ( course )

The tutorial is as follows : need 1 A picture ( Customizable )

1. Photo cutting ( course )

First : Download Meitu XiuXiu / Baidu download / Or software installation
Or use online links to crop —> Online clip image links
 Insert picture description here

2. Meitu Xiu Xiu ( Computer version ) Cut the picture

1 Select the picture you want to cut

 Insert picture description here

2. It is recommended to reduce the size of the picture in 600px *600px about Otherwise the picture is too big , The page will be stuck
 Insert picture description here
3… Save photos
 Insert picture description here
 Insert picture description here

3、 ... and 、 song mp3 Replace tutorial ( course )

If it needs to be replaced mp3 The background music , You can download and replace it by yourself ~ mp3 Free download address
1. Search for songs you need

 Insert picture description here

2. download
 Insert picture description here

3 Get songs id
 Insert picture description here

4 Pay attention to the official account. / Copy link to browser open

 Insert picture description here

5 download mp3 ~ After downloading, replace it by yourself mp3 File can ( If you don't want to modify the code , The name must be consistent )
 Insert picture description here


Four 、 Good web effect , How to send links to others ?

1.1 Solve the deployment online ~> Deploy online tools ( It can be used permanently and free of charge )

1. You don't need to buy a server to deploy online , Your connection is accessible all over the world , Here is a necessary artifact for programmers ~
Plugins are integrated with super easy-to-use plug-ins , Download and install for free , Simple and easy to understand , It's an artifact ~ If necessary, it can be found in the article ↓ Xiagong Z Number acquisition

2. Is to do your code effect well , Deploy online , Send links to others , You can let the other party click in through your connection , You can see the effect of your web page , Both computer and mobile terminals are OK ! ( Otherwise, people will send files when they see your web page , The experience is not very good ~)

1.1 Deployment process

 Insert picture description here

1.2 wow ~ Deployment success

wow ~ Deployment success ! Deploy your written page online , People all over the world can access your web page through links ( Free forever )~
 Insert picture description here


5、 ... and 、 front end Zero basis Entry to advanced ( video + Source code + Development software + Learning materials + Interview questions ) a full set of ( course )

Suitable for children's shoes from entry to advanced ~
 Insert picture description here


6、 ... and 、* The source code for

* ~ Pay attention to me , Like the blog ~ Every day brings you knowledge !

* 1. See here, just [ give the thumbs-up + Praise + Collection ] Three even ~ Support me , Yours 「 give the thumbs-up , Praise , Collection 」 It's the driving force of my creation .

* 2. Pay attention to me ~ Take you to study every day : Various front-end plug-ins 、3D Cool effect 、 Pictures show 、 Text effect 、 And the whole station template 、 College graduation template 、 Final assignment template 、 etc. ! 「 There are a lot of front end developer , To discuss front end Node knowledge , learn from each other 」!

* 3. We can learn from each other about the above technical issues , can Focus on ↓ Male Z Number Get more source code !

 Insert picture description here


7、 ... and 、* More confession source code

100 Paragraph confession source code demonstration address

copyright notice
author[@. code out the future],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2021/08/20210822225441466x.html

Random recommended