前言
程序猿是什么样一个群体?很多人都认为程序猿木讷,去邻家妹妹家只有一个目的:修电脑。程序猿还会经常加班,很少陪女朋友,女朋友不舒服只会让她们多喝热水,女朋友生起气来可能在他们眼里就是一段出了BUG的代码,当然前提是他们要有女朋友……
你说程序猿整天只会敲代码一点也不懂浪漫?那你可能有一个假程序猿男朋友
马上就要到520的网络情人节了,土味程序员来一波土味浪漫。。。。。。
8个表白小网址,只列出来了五个,提供源码下载
展示网址:点击查看
先来第一个
按照自己的需要修改js即可
const blk_pitn = { //各小方块相对【自身中心】的位置 -- 【自身中心】确定为#div22的方块
block1: [[0, 1], [0, 0], [-1, 0], [-1, -1]],
block2: [[0, 1], [0, 0], [-1, 0], [0, -1]],
block3: [[-1, 1], [0, 0], [-1, 0], [-1, -1]],
block4: [[0, 1], [0, 0], [-1, 0], [-1, -1]], /* 1 */
block5: [[-1, 1], [0, 0], [-1, 0], [0, -1]],
block6: [[0, -1], [0, 0], [-1, 0], [1, -1]],
block7: [[-1, -1], [0, 0], [-1, 0], [1, 0]],
block8: [[-1, 1], [0, 0], [-1, 0], [-1, -1]], /* 3 */
block9: [[0, -1], [0, 0], [-1, 0], [1, 0]],
block10: [[-1, 1], [0, 0], [-1, 0], [1, 0]],
block11: [[2, 0], [0, 0], [-1, 0], [1, 0]], /* — */
block12: [[0, 1], [0, 0], [-1, 0], [0, -1]], /* 2 */
block13: [[0, 1], [0, 0], [-1, 0], [-1, -1]], /* 1 */
block14: [[1, 1], [0, 0], [-1, 0], [1, 0]],
block15: [[1, -1], [0, 0], [-1, 0], [1, 0]],
block16: [[-1, -1], [0, 0], [-1, 0], [1, 0]], /* 7 */
block17: [[0, 1], [0, 0], [-1, 0], [0, -1]], /* 2 */
block18: [[0, 1], [0, 0], [-1, 0], [-1, -1]], /* 1 */
block19: [[0, -1], [0, 0], [-1, 0], [1, 0]], /* 9 */
block20: [[1, -1], [0, 0], [-1, 0], [1, 0]],
block21: [[0, 1], [0, 0], [-1, 0], [-1, -1]], /* 1 */
block22: [[1, 1], [0, 0], [-1, 0], [1, 0]], /* 14 */
block23: [[0, 2], [0, 0], [0, -1], [0, 1]] /* | */
},
offset_pitn = { //各方块block相对【爱心中心】的位置
block1: [5, 3],
block2: [5, 1],
block3: [3, 4],
block4: [3, 2],
block5: [3, -1],
block6: [2, 5],
block7: [2, 1],
block8: [1, -1],
block9: [1, -3],
block10: [1, 2],
block11: [0, 3],
block12: [0, 0], /* 【爱心中心】*/
block13: [-1, -4],
block14: [0, -2],
block15: [-2, 4],
block16: [-2, 2],
block17: [-2, 0],
block18: [-3, -2],
block19: [-4, 0],
block20: [-3, 5],
block21: [-5, 3],
block22: [-4, 1],
block23: [-6, 1] /* 因动画需要移动一个方块,故y轴坐标-1*/
};
let blocks = document.getElementsByClassName("block"),
block = blocks[0],
love = document.getElementsByClassName("love")[0],
timer = null,
index = 0, //记录拼接爱心的动画步骤
clone_block; //用于克隆方块
//1.移动方块的【自身中心】到【爱心中心】
block.style.top = "50%";
block.style.left = "50%";
block.style.margin = "-20px 0 0 -20px";
const block_left = parseFloat(window.getComputedStyle(block, null).left.slice(0, -2)), //【爱心中心】 左边距离父元素的距离
block_top = parseFloat(window.getComputedStyle(block, null).top.slice(0, -2)); //【爱心中心】 顶部距离父元素的距离
function Next() {
if (++index >= 24) {
clearInterval(timer);
Rise();
// alert("已经是最后一个了!");
return;
}
block.style.visibility = "visible"; //升空动画前允许可见
//2.移动方块到指定的位置-即是移动【自身中心】到目标位置
block.style.left = block_left + 40 * offset_pitn["block" + index][0] + "px";
block.style.top = block_top - 40 * offset_pitn["block" + index][1] + "px";
for (let i = 0; i < block.children.length; i++) {
// block.children[1].innerText = index; //编号便于调试
block.children[i].style.left = blk_pitn["block" + index][i][0] * -40 + "px";
/* -40 是因为逻辑坐标和浏览器的x,y轴方向不一样*/
block.children[i].style.top = blk_pitn["block" + index][i][1] * -40 + "px";
}
//3.克隆方块—保存现在的位置
/* 一共会克隆23个方块,加上原先的一个方块block,共24个方块,即多出原先的block方块*/
clone_block = block.cloneNode(true);
love.appendChild(clone_block);
if (love.children.length >= 24) {
blocks[blocks.length - 1].children[2].style.display = "none"; //去掉多余的小方块
block.style.display = "none"; //隐藏多出的block方块
}
}
function Rise() {
//4.爱心升高,多出的那个小方块开始掉落
console.log("开始升空");
let timer2 = null,
distance = 0;
/* 升高时,移动的距离*/
const target = 120, /* 目标距离*/
speed = 1;
/*移动速度*/
let love_top = parseFloat(window.getComputedStyle(love, null).top.slice(0, -2)); //爱心盒子距离屏幕顶部的距离
timer2 = setInterval(() => {
distance += speed;
// console.log(distance);
if (distance >= target) {
clearInterval(timer2);
console.log("升空完毕");
}
love.style.top = (love_top - distance) + "px";
}, 22);
}
window.onload = function () {
setTimeout(() => {
timer = setInterval(() => {
Next();
}, 300);
}, 12000); //gif图播放完毕所需时间为11.73s
};
第二个
这个就比较调皮啦,嘿嘿嘿,想查看可以访问上面的链接
展示网址:点击查看
看看这个代码也知道会出现什么样的效果哦,
再往下就不贴代码啦,只放出样式图,自己去下载就可。免费的
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<title>forever love</title>
</head>
<script src="js/lib/jquery.min.js" type="text/javascript"></script>
<script src="js/lib/jquery.fireworks.js" type="text/javascript"></script>
<style type="text/css">
*{ -webkit-tap-highlight-color:rgba(0,0,0,0); -webkit-box-sizing: border-box; box-sizing: border-box; }
html{ width: 100%; height: 100%; }
body{ max-width: 600px; margin: 0 auto; background: #0b3443; color: #f0f0f0;}
.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: #d26ae5; }
.btn-b{ background: #c9c9c9; }
.btn-a:before{ content: ''; position: absolute; display: block; width: 30px; height: 60px; background: #d26ae5; left: -29px; top: 0; border-top-left-radius: 60px; border-bottom-left-radius: 60px; }
.btn-a:after{ content: ''; position: absolute; display: block; width: 60px; height: 30px; background: #d26ae5; left: 0; top: -29px; border-top-left-radius: 60px; border-top-right-radius: 60px;}
.btn-b:before{ content: ''; position: absolute; display: block; width: 30px; height: 60px; background: #c9c9c9; left: -29px; top: 0; border-top-left-radius: 60px; border-bottom-left-radius: 60px; }
.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: 80%; height: 160px; position: absolute; top: 50%; left: 50%; padding: 20px 15px; border-radius: 5px; transform: translate(-50%, -70%); -webkit-transform: translate(-50%,-70%); background: #f3f3f3;}
.container .modal p{ margin-top: 20px; margin-bottom: 20px; font-size: 16px; color: #353535; text-align: center;}
.confirm{ display: block; width: 120px; height: 40px; margin: 0 auto; border: none; font-size: 16px; border-radius: 5px; color: #ffffff; background: #f45cae; }
.type_words{ padding: 12px 20px; }
@keyframes breath {
0% {
transform: scale3d(1,1,1);
-webkit-transform: scale3d(1,1,1);
transform-origin: 50% 50%;
}
50%{
transform: scale3d(1.02,1.02,1.02);
-webkit-transform: scale3d(1.02,1.02,1.02);
transform-origin: 50% 50%;
}
100%{
transform: scale3d(1,1,1);
-webkit-transform: scale3d(1,1,1);
transform-origin: 50% 50%;
}
}
</style>
<script type="text/javascript">
$(function() {
$('#yes').click(function(event) {
modal('我就知道小姐姐您一定会愿意的。(^_^)', function() {
$('.page_one').addClass('hide');
$('.page_two').removeClass('hide');
// typeWrite();
fireworks();
});
});
$('#no').click(function(event) {
modal('明人不说暗话!', A);
});
});
function A() {
modal('我喜欢你!', B);
}
function B() {
modal('我知道你在等我这一句话', C);
}
function C() {
modal('请您不要拒绝我', D);
}
function D() {
modal('拒绝我,不存在的', E);
}
function E() {
modal('这辈子都不可能让你离开我', F);
}
function F() {
modal('跟我走吧', G);
}
function G() {
modal('房产证上写你名', H);
}
function H() {
modal('我会做饭', I);
}
function I() {
modal('爱你。么么哒!', J)
}
function J() {
modal('行,我们去民政局登记吧', function() {
fireworks();
});
}
function fireworks() {
$('.page_one').addClass('hide');
$('.page_two').removeClass('hide');
$('.page_two').fireworks({
sound: false,
opacity: 0.9,
width: '100%',
height: '100%'
});
}
function modal(content, callback) {
var tpl = '<div class="container">'+
'<div class="mask"></div>'+
'<div class="modal">'+
'<p>'+ content +'</p>'+
'<button type="button" id="confirm" class="confirm">确定</button>'+
'</div>'+
'</div>';
$('body').append(tpl);
$(document).on('click', '.confirm', function() {
$('.container').remove();
callback();
});
}
var myWords = '有人说,人的一生会遇到2920万人,而两个人相爱的概率只有0.000049。在这茫茫人海中,两个人能相遇就值得感激,能相爱更是一种难得。所以,我很庆幸上天让我遇见了你。我希望有个如你一般的人,能看完我写过的所有状态,读完我所有的日志,看完我从小到大的照片,试着听我喜欢的歌。如果可以,甚至陪我去我喜欢的地方,只想弥补错过你的青春。';
var x = 0;
var speed = 150;
var current = 0;
function typeWrite(){
$('.type_words').html(myWords.substring(0, x++)+'_');
var timer = setTimeout("typeWrite()", speed);
if (x == myWords.length) {
x = myWords.length;
clearTimeout(timer)
}
}
</script>
<body>
<div class="share_img"><img src="images/a8b.png" alt=""></div>
<div class="page_one">
<div class="content">
<div class="text_wrapper">
<img src="images/a8.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>
<div class="page_two hide">
<div class="type_words"></div>
</div>
</body>
</html>
第三个
第四个
第五个
这个如果想要改时间,在index.html文件中的下部就可以更改
这个就是要更改的位置
var textAnimate = eval(Jscex.compile("async", function () {
var together = new Date();
together.setFullYear(2010,1 , 15); //时间年月日
together.setHours(16); //小时
together.setMinutes(53); //分钟
together.setSeconds(0); //秒前一位
together.setMilliseconds(2); //秒第二位
$("#code").show().typewriter();
$("#clock-box").fadeIn(500);
while (true) {
timeElapse(together);
$await(Jscex.Async.sleep(1000));
}
}));