编程知识 cdmana.com

圣诞节送女友 html+css+js 炫酷烟花表白(含音乐) 程序员表白

助力程序员撩妹手到擒来 html+css+js 烟花表白(含音乐)可自定义编辑文字

圣诞节快到了,是不是要给女朋友或者正在追求的妹子一点小惊喜呢 ? html+css+js 编写的抖音烟花表白效果,酷炫迷人,助力程序员撩妹手到擒来,一帆风顺,祝愿大家有情人终成眷属,天长地久。。赶紧学会了,来制作属于我们程序员的浪漫吧!

Web前端基于Canvas实现的烟花表白特效,基于对Canvas的理解实现,总会有那么一段小惊喜,可以惊艳到彼此短暂的时光。

制作不易,需要源码的朋友 添加qq 365392777

更多表白方式可点击下方链接:

女朋友生日 HTML+css3+js 实现抖音炫酷樱花3D相册 (含背景音乐)程序员表白必备


动态效果图(已兼容 H5移动端 和 pc端 )

在线演示地址

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

人狠话不多,直接上代码

文件结构

在这里插入图片描述

html部分


<!--
 * @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\酷炫表白烟花\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>
        炫酷烟花表白
    </title>
    <!-- 弹窗样式 -->
    <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>
  
<!--对话部分-->
<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">
                小姐姐,我好喜欢你,你愿意做我女朋友吗?
            </div>
        </div>
    </div>
    <div class="btn-groups">
        <div class="heart-btn">
            <div id="yes" class="btn btn-a"><span>愿意</span></div>
        </div>
        <div id="no" class="btn btn-b"><span>不愿意</span></div>
    </div>
</div>
<!--烟花部分-->
<canvas id='cas' style="background-color:rgba(0,5,24,1); z-index: 9999;">
    浏览器不支持canvas
</canvas>
<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">
       这里自定义文字
    </div>
    <div class="shape">
        茫茫人海
    </div>
    <div class="shape">
        相遇是缘
    </div>
    <div class="shape">
        我爱你直到永远
    </div>
</div>
<!--音乐部分-->
<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>
... 制作不易,需要源码的朋友 请添加 365392777
</html>

css 部分

* {
   
    
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
.share_img {
   
    
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
}
.content {
   
    
  /* padding: 80px 20px; */
}
.text_wrapper {
   
    
  display: -webkit-box;
  display: flex;
}
.text_wrapper .text {
   
    
  padding-top: 20px;
  padding-left: 20px;
}
.hide {
   
    
  display: none !important;
}
p {
   
    
  margin: 0;
}
.btn-groups {
   
    
  padding-right: 20px;
  text-align: center;
}
.heart-btn {
   
    
  display: inline-block;
  animation: breath 0.8s linear 0s infinite both;
  -webkit-animation: breath 0.8s linear 0s infinite both;
}
.btn {
   
    
  position: relative;
  display: inline-block;
  width: 60px;
  height: 60px;
  margin: 0 30px;
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
}
.btn span {
   
    
  display: block;
  width: 100%;
  height: 100%;
  line-height: 60px;
  margin-top: -10px;
  margin-left: -10px;
  text-align: center;
  transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg);
}
/* 愿意 */
.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%;
}
... 制作不易,需要源码的朋友 请添加 365392777

js部分

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)
    };
canvas.onclick = function() {
   
    
    var x = event.clientX;
    var y = event.clientY;
    var bigboom = new Boom(getRandom(canvas.width / 3, canvas.width * 2 / 3), 2, "#FFF", {
   
    
        x: x,
        y: y
    });
    bigbooms.push(bigboom)
};
var Boom = function(x, r, c, boomArea, shape) {
   
    
    this.booms = [];
    this.x = x;
    this.y = (canvas.height + r);
    this.r = r;
    this.c = c;
    this.shape = shape || false;
    this.boomArea = boomArea;
    this.theta = 0;
    this.dead = false;
    this.ba = parseInt(getRandom(80, 200))
};
Boom.prototype = {
   
    
    _paint: function() {
   
    
        ctx.save();
        ctx.beginPath();
        ctx.arc(this.x, this.y, this.r, 0, 2 * Math.PI);
        ctx.fillStyle = this.c;
        ctx.fill();
        ctx.restore()
    },
    _move: function() {
   
    
        var dx = this.boomArea.x - this.x,
            dy = this.boomArea.y - this.y;
        this.x = this.x + dx * 0.01;
        this.y = this.y + dy * 0.01;
        if (Math.abs(dx) <= this.ba && Math.abs(dy) <= this.ba) {
   
    
            if (this.shape) {
   
    
                this._shapBoom()
            } else {
   
    
                this._boom()
            }
            this.dead = true
        } else {
   
    
            this._paint()
        }
    },
    _drawLight: function() {
   
    
        ctx.save();
        ctx.fillStyle = "rgba(255,228,150,0.3)";
        ctx.beginPath();
        ctx.arc(this.x, this.y, this.r + 3 * Math.random() + 1, 0, 2 * Math.PI);
        ctx.fill();
        ctx.restore()
    },
    _boom: function() {
   
    
        var fragNum = getRandom(30, 200);
        var style = getRandom(0, 10) >= 5 ? 1 : 2;
        var color;
        if (style === 1) {
   
    
            color = {
   
    
                a: parseInt(getRandom(128, 255)),
                b: parseInt(getRandom(128, 255)),
                c: parseInt(getRandom(128, 255))
            }
        }
Frag.prototype = {
   
    
    paint: function() {
   
    
        ctx.save();
        ctx.beginPath();
        ctx.arc(this.x, this.y, this.radius, 0, 2 * Math.PI);
        ctx.fillStyle = "rgba(" + this.color.a + "," + this.color.b + "," + this.color.c + ",1)";
        ctx.fill();
        ctx.restore()
    },
    moveTo: function(index) {
   
    
        this.ty = this.ty + 0.3;
        var dx = this.tx - this.x,
            dy = this.ty - this.y;
        this.x = Math.abs(dx) < 0.1 ? this.tx: (this.x + dx * 0.1);
        this.y = Math.abs(dy) < 0.1 ? this.ty: (this.y + dy * 0.1);
        if (dx === 0 && Math.abs(dy) <= 80) {
   
    
            this.dead = true
        }
        this.paint()
    }
};
... 制作不易,需要源码的朋友 请添加 365392777

更多源码

1.echart在线演示地址

2.基于 Echarts 实现可视化数据大屏响应式展示效果的源码,共计100套,可以在此基础上重新开发(vue/react)都可以使用

3.女朋友生日 HTML+css3+js 实现抖音炫酷樱花3D相册 (含背景音乐)程序员表白必备

4.[免费部署上线工具]->不需要服务器就能将项目部署上线

5.前端 html+css+js[1000个超炫酷特效] 当我学会这招,所有炫酷的特效页面(含源码)都能下载下来啦!

6.抖音超火罗盘时钟(免费附源码)

一万年太长,和你在一起,只争朝夕。
情书给你一封,情话给你一句,余生给你一人。
我想要的未来,就是每天早上起床,都能看见你和阳光都在。

版权声明
本文为[osc_p4wgjz7p]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4292686/blog/4839785

Scroll to Top