n7模板 帖子页面 右侧用户栏添加一个tips

[复制链接]
aoki(UID:59) 发表于 2025-1-27 16:27:12 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×

n7模板 帖子页面 右侧用户栏添加一个tips

n7模板 帖子页面 右侧用户栏添加一个tips
/template/discuz_theme_n7/forum/viewthread.php
438处<div id="comiis_viewthread_sidetop_div"></div>上方合适地位

  1.     <div class="custom-tip"><p>💡 <strong>Tips:</strong> <span id="random-text"></span></p></div>
  2.     <script src="https://www.jiubbs.cn/s/js/tips.js"></script>
  3.     <style>
  4.     .custom-tip {
  5.     margin-top: 10px;
  6.     padding: 5px;
  7.     /*background-color: #f8f9fa;
  8.     border: 1px solid #dee2e6;*/
  9.     border-radius: 5px;
  10.     font-size: 12px;
  11.     color: #6c757d;
  12. }
  13.      </style>
复制代码
狐狸导航:https://www.foxccs.cn/
全部回复2 显示全部楼层
猫大仙(UID:166) 发表于 2025-4-19 21:08:41 | 显示全部楼层
tips.js这个文件路径好像失效了,没有内容显示。
aoki(UID:59) 发表于 7 天前 | 显示全部楼层
猫大仙 发表于 2025-4-19 21:08
tips.js这个文件路径好像失效了,没有内容显示。

https://www.jiubbs.cn/s/js/tips.js  


  1.     // 从/tips.json 文件加载数据
  2. fetch('//www.jiubbs.cn/s/js/tips.json')
  3.         .then(response => response.json()) // 解析为 JSON
  4.         .then(data => {
  5.             const randomTexts = data.tips; // 获取提示数组
  6.             let currentIndex = 0; // 当前提示索引
  7.             
  8.             // 函数用于更新显示的提示
  9.             const updateTip = () => {
  10.                 const selectedText = randomTexts[currentIndex];
  11.                 const randomTextElement = document.getElementById('random-text');

  12.                 // 更新提示文本
  13.                 randomTextElement.textContent = selectedText;
  14.                 randomTextElement.style.transform = 'translateY(0)'; // 初始化位置

  15.                 // 设置下一条提示
  16.                 currentIndex = (currentIndex + 1) % randomTexts.length;

  17.                 // 动画效果
  18.                 setTimeout(() => {
  19.                     randomTextElement.style.transform = 'translateY(-100%)'; // 向上移动
  20.                 }, 3000); // 3秒后开始移动

  21.                 // 循环调用更新提示
  22.                 setTimeout(updateTip, 4000); // 4秒后更新提示(3秒显示 + 1秒移动)
  23.             };

  24.             // 初始化提示
  25.             updateTip();
  26.         })
  27.         .catch(error => {
  28.             console.error('加载数据失败:', error);
  29.         });
复制代码
狐狸导航:https://www.foxccs.cn/

快速回帖

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1楼
2楼
3楼

关于楼主

学步前行
  • 主题

    84
  • 回答

    33
  • 积分

    406
虚位以待,此位置招租
虚位以待,此位置招租

商务推广

    此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租 此位置招租
最新热评 加载中...