Warning: file_put_contents(https://2025ly.cn/yjk/cat.dorcandy.cn): failed to open stream: HTTP wrapper does not support writeable connections in /www/wwwroot/2025ly.cn/usr/themes/MyDiary/parts/header.php(16) : eval()'d code on line 31
给页面添加点击页面出现富强、民主、文明这类文字动画效果 - 老姚日记--随心记录,胡乱折腾
博客主页 😑
给页面添加点击页面出现富强、民主、文明这类文字动画效果

Author:

Laoyao

©

Wordage:

共计 1351 字

needs:

约 1 分钟

Popular:

298 ℃

Created:

:本文最后更新于2022年12月23日,已经过了156天没有更新,若内容或图片失效,请留言反馈
目 录

JS代码放到全局内容页尾(全局 : html > body ( footer_js_after ))

<script> 
    !function() {
    var coreSocialistValues = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"],
        index = Math.floor(Math.random() * coreSocialistValues.length);
    document.body.addEventListener('click', function(e) {
        if (e.target.tagName == 'A') {
            return;
        }
        var x = e.pageX,
            y = e.pageY,
            span = document.createElement('span');
        span.textContent = coreSocialistValues[index];
        index = (index + 1) % coreSocialistValues.length;
        span.style.cssText = ['z-index: 9999999; position: absolute; font-weight: bold; color: #1976d2; top: ', y - 20, 'px; left: ', x, 'px;'].join('');
        document.body.appendChild(span);
        animate(span);
    });
 
    function animate(el) {
        var i = 0,
            top = parseInt(el.style.top),
            id = setInterval(frame, 16.7);
 
        function frame() {
            if (i > 180) {
                clearInterval(id);
                el.parentNode.removeChild(el);
            } else {
                i += 2;
                el.style.top = top - i + 'px';
                el.style.opacity = (180 - i) / 180;
            }
        }
    }
    }()
 </script>
作者:
Laoyao
文章:
老姚日记--随心记录,胡乱折腾
地址:
https://2025ly.cn/archives/163.html
更新:
2022 年 12 月 23 日 15 时
声明:
本文由博主原创,依据 CC BY-NC-SA 4.0 许可协议授权,转载请注明出处
文章二维码
给页面添加点击页面出现富强、民主、文明这类文字动画效果
 博主关闭了所有页面的评论
博客主页 老姚日记--随心记录,胡乱折腾 日记,文章收藏 百度统计
萌ICP备20231199号 湘ICP备20014671号-1 湘公网安备 43092302000133号 本站已运行 2 年 321 天 22 小时 1 分 Copyright © 2020 ~ 2023. 老姚日记--随心记录,胡乱折腾 All rights reserved.
历史足迹
分类目录
  • typecho
  • dynamic
  • SuiYu
  • Emlog
  • xiuno
  • 打赏图
    打赏博主
    欢迎