网页鼠标点击特效


分享几个之前用过的鼠标点击特效,美化一下网页也是挺不错的。

鼠标点击心形特效

1
2
3
<script type="text/javascript">
!function (e, t, a) {function r() {for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");requestAnimationFrame(r)}function n() {var t = "function" == typeof e.onclick && e.onclick;e.onclick = function (e) {t && t(), o(e)}}function o(e) {var a = t.createElement("div");a.className = "heart", s.push({el: a,x: e.clientX - 5,y: e.clientY - 5,scale: 1,alpha: 1,color: c()}), t.body.appendChild(a)}function i(e) {var a = t.createElement("style");a.type = "text/css";try {a.appendChild(t.createTextNode(e))} catch (t) {a.styleSheet.cssText = e}t.getElementsByTagName("head")[0].appendChild(a)}function c() {return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"}var s = [];e.requestAnimationFrame = e.requestAnimationFrame e.webkitRequestAnimationFrame e.mozRequestAnimationFrame e.oRequestAnimationFrame e.msRequestAnimationFrame function (e) {setTimeout(e, 1e3 / 60)}, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()}(window, document);
</script>

鼠标点击文字特效

可自行更换文字。另外依赖jquery,必须引用才能显示。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<script type="text/javascript">
var a_idx = 0;
jQuery(document).ready(function($) {
$("body").click(function(e) {
var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正" ,"法治", "爱国", "敬业", "诚信", "友善");
var $i = $("<span/>").text(a[a_idx]);
a_idx = (a_idx + 1) % a.length;
var x = e.pageX,
y = e.pageY;
$i.css({
"z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
"top": y - 20,
"left": x,
"position": "absolute",
"font-weight": "bold",
"color": "#ff6651"
});
$("body").append($i);
$i.animate({
"top": y - 180,
"opacity": 0
},
1500,
function() {
$i.remove();
});
});
});
</script>

鼠标点击气泡特效

下载地址:https://pan.baidu.com/s/1yMtmELoekPyef4wwPTJS6w提取码:iq23

下载解压之后,将两个js文件与一个css文件上传至wordpress主题目录下,接着再将以下代码写入主题的头部文件(head.php)当中,注意修改路径为自己的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<style>
.fireworks {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<canvas class=”fireworks” style=”position:fixed;left:0;top:0;z-index:99999999;pointer-events:none;”></canvas>
<script src=”https://www.tzrseo.com/wp-content/themes/justnews/anime.min.js”></script>
<script src=”https://www.tzrseo.com/wp-content/themes/justnews/cursor.js”></script>
<script type=”text/javascript”>
fireworks.setCanvasSize();
</script>

原文:https://www.tzrseo.com/tougao/1727.html


文章作者: COOL
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 COOL !
评论
  目录