网页点击特效 - 鼠标点击浮现爱心特效

效果演示 >> https://Blog.7Core.CN
         >> https://blog.7core.cn/thread-26.htm (本文)任意处点击左键即可看到效果

推荐配合价值观特效使用:https://blog.7core.cn/thread-25.htm


将以下内容插入到< html >标签内即可

<script type="text/javascript">
        /*7Core-CN - 网页鼠标点击特效(爱心)*/
        !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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 原文地址(推荐):https://blog.7core.cn/thread-25.htm 效果演示 >> http...
    0f534b43b700阅读 6,380评论 0 2
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,046评论 25 709
  • 荐 语 这本书的作者是史蒂芬·柯维,他的成名作《高效能人士的七个习惯》影响了全球大量成功人士。 这本书是柯维去世前...
    晨峰_02c6阅读 3,462评论 0 0
  • 期末来临,听说大学老师出题有套路,被笑哭... 盼望着盼望着 可以开着空调抱着西瓜 洋洋洒洒的暑假 又双叒叕来啦 ...
    gdlyz阅读 5,747评论 0 0
  • 夏日的一个午后 我在倾听蝉的音乐 偶然间 一个少年路过我的窗台 微风吹着他的发梢 他抬眼擦去额角的汗珠 对着天空微...
    灰姑娘hh阅读 2,548评论 0 1