Skip to content

Commit

Permalink
新增博客上常见的点击页面出现心型符号动画
Browse files Browse the repository at this point in the history
  • Loading branch information
qinchao888 committed Dec 18, 2019
1 parent 2586bdd commit ab1d0cf
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
### 点击按钮实现放大缩小动画 - scale.html
### 点击按钮实现放大缩小动画 - scale.html

### 博客上常见的点击页面出现心型符号 - heart.html
41 changes: 41 additions & 0 deletions heart.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>heart</title>
</head>
<style>
body {
user-select: none;
}
</style>
<body>
</body>
<script>
(function () {
var index = 0;
document.onclick = function (event) {
index++;
var x = event.clientX;
var y = event.clientY;
var keyframes = '@keyframes move' + index + '{from {display: block;} to {display: none; top:' + (y - 100 ) + 'px; opacity: 0;}}';
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = keyframes;
head.appendChild(style);
var color = '#' + ((Math.random() * 0xffffff + 1) | 0).toString(16).padStart(6, '0'); // 需要补齐六位
var div = document.createElement('div');
div.innerHTML = '❤';
div.style = 'font-size:24px;color:' + color + ';' + 'position:fixed;animation: move' + index + ' 2s ease;' + 'left:' + x + 'px;top:' + y + 'px;';
document.body.appendChild(div);
setTimeout(function () {
document.getElementsByTagName('head')[0].removeChild(style);
document.body.removeChild(div);
}, 2000);
}
})()
</script>
</html>
2 changes: 1 addition & 1 deletion scale.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<title>scale</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
html, body {
Expand Down

0 comments on commit ab1d0cf

Please sign in to comment.