🎅挂件馆🌟铭牌馆✨️靓标库🧚‍♂️名人堂🦄宝可梦🍎水果机🥊猜拳🏧黑市🏧银行💹抽奖
   🎁
返回列表 发布新帖
查看: 248|回复: 0

[代码技巧] 子比主题 – 帖子角标与标签修改美化版

[复制链接]
飞流 00001
起源之星
任务·年会员
累计签到LV.3
摩羯座
+1
社区贡献
346 220 24796
等级头衔
Icon组别 : 管理员
Icon等级 :

积分成就
   钻石 : 165 颗
   贡献 : 24991 点
   金币 : 4 枚
Icon在线时间 : 1974 小时
Icon注册时间 : 2024-11-22
Icon最后登录 : 2026-9-14
送礼物:3 收礼物:1
FLLTCN 实名认证 特邀大神 诚信商家 信誉担保 精华作者+ 官方团队 vip vip-year 发表于 2025-10-5 22:06:23 | 查看全部 |阅读模式 浙江金华

交易无需等待,成交就是现在,全面资源整合网络大咖云集,让你轻松玩转互联网!

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

×
这是一款子比主题论坛,是论坛,不是文章,论坛的一款左上角角标和右边标签修改美化版,很多人想要一种简约的,今天的这款美化也是算挺简约好看,喜欢的自行部署吧!
O1CN01OWtyBN1QbIqkBPLib_!!2210123621994.gif.webp
首先定位:子比主题–>>社区&论坛–>>首页设置–>>综合–>>我们将列表样式改成简约,别忘了~
然后接下来就可以部署我们的代码,一共三个代码,话不多说直接开始!
posts.php文件
定位:/zibll/inc/functions/bbs/inc/posts.php,我们打开这个文件之后,搜下面的函数代码!
  1. zib_bbs_get_posts_mini_list
复制代码
把上面的整个函数替换成下面的代码即可!
  1. //标签
  2. function zib_bbs_get_posts_mini_list($class = 'ajax-item', $show_topping = false)
  3. {
  4.     $class = $class ? ' ' . $class : '';
  5.     global $post;
  6.     $term_links = zib_bbs_get_posts_tag_link($post->ID, 'liuke-biaoqian');
  7.     $term_html = '';
  8.     if ($term_links) {
  9.         $term_html .= '<div class="tag-wrapper">';
  10.         $term_html .= '<div class="tag-container">' . $term_links . '</div>';
  11.         $term_html .= '</div>';
  12.     }
  13.     $plate_id = zib_bbs_get_plate_id($post->ID);
  14.     $plate_name = get_the_title($plate_id);
  15.     $plate_link = get_permalink($plate_id);
  16.     $plate_badge = '<a href="' . esc_url($plate_link) . '" class="plate-badge">' .
  17.                    '<i class="fa fa-comments-o" aria-hidden="true"></i> ' .
  18.                    '<span class="plate-name">' . esc_html($plate_name) . '</span>' .
  19.                    '</a>';
  20.     $title = zib_bbs_get_posts_lists_title('forum-title flex ac', 'text-ellipsis', $show_topping, true);
  21.     $title = preg_replace('/(<a.*?class=".*?text-ellipsis.*?".*?>.*?<\/a>)/', '$1' . $term_html, $title, 1);
  22.     // $title             = zib_bbs_get_posts_lists_title('forum-title flex ac', 'text-ellipsis', $show_topping, true);
  23.     $author_id         = get_the_author_meta('ID');
  24.     $display_name_link = zib_get_user_name($author_id);
  25.     $avatar_html       = '<div class="mr20 forum-user">';
  26.     $avatar_html .= zib_get_avatar_box($author_id, 'avatar-img forum-avatar');
  27.     $avatar_html .= '<span class="show-sm ml6 flex ac" style="width: 90%;">' . $display_name_link . '</span>';
  28.     $avatar_html .= '</div>';

  29.     $info_top = '';
  30.     $info_top .= $title;

  31.     $last_reply       = get_post_meta($post->ID, 'last_reply', true);
  32.     $get_the_time     = get_the_time('Y-m-d H:i:s');
  33.     $get_the_time_ago = zib_get_time_ago($get_the_time);

  34.     if ($last_reply) {
  35.         $time = '<span class="icon-circle" title="最后回复:' . $last_reply . '">' . zib_get_time_ago($last_reply) . '回复</span>';
  36.     } else {
  37.         $time = '<span class="icon-circle" title="发布时间:' . $get_the_time . '">' . $get_the_time_ago . '发布</span>';
  38.     }

  39.     if ('publish' !== $post->post_status) {
  40.         $icon_meta = zib_bbs_get_posts_more_dropdown($post->ID, 'pull-right mrn10', 'padding-10 opacity8');
  41.     } else {
  42.         $icon_meta = zib_bbs_get_posts_icon_metas();
  43.     }

  44.     $info_down = '<div class="flex ac jsb item-meta">';
  45.     $info_down .= '<div class="meta-left em09-sm flex">';
  46.     $info_down .= '<span class="hide-sm">' . $display_name_link . '</span>';
  47.     $info_down .= $time;
  48.     $info_down .= '</div>';
  49.     $info_down .= '<div class="meta-right">' . $icon_meta . '</div>';
  50.     $info_down .= '</div>';

  51.     $info_html = '<div class="entry-info">';
  52.     $info_html .= $plate_badge;
  53.     $info_html .= $info_top;
  54.     $info_html .= $info_down;
  55.     $info_html .= '</div>';

  56.     $html = '<posts class="forum-posts mini' . $class . '">';
  57.     $html .= $avatar_html;
  58.     $html .= $info_html;
  59.     $html .= '</posts>';

  60.     return $html;
  61. }
  62. //标签
复制代码
CSS代码
将下面的代码放到子比主题–>>自定义CSS样式即可!
  1. /*帖子左上角标识*/
  2. .tag-wrapper {
  3.     position: absolute;
  4.     right: 0;
  5.     top: 50%;
  6.     transform: translateY(-50%);
  7.     overflow: hidden;
  8.     white-space: nowrap;
  9.     transition: width 0.3s ease;
  10. }
  11. .tag-container {
  12.     display: inline-flex;
  13.     transition: transform 0.3s ease;
  14.     border-radius: 6px;
  15.     overflow: hidden;
  16.     box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  17. }
  18. a.liuke-biaoqian.tag-link {
  19.     font-size: 10px;
  20.     padding: 1px 5px;
  21.     text-decoration: none;
  22.     display: inline-block;
  23.     transition: all 0.3s ease;
  24.     font-weight: 500;
  25.     line-height: 20px;
  26.     border: none;
  27.     outline: none !important;
  28.     opacity: 1;
  29.     visibility: visible;
  30.     margin: 0;
  31.     border-radius: 0;
  32. }
  33. a.liuke-biaoqian.tag-link:first-child {
  34.     border-top-left-radius: 6px;
  35.     border-bottom-left-radius: 6px;
  36. }
  37. /*6ke论坛 https://6.ke*/
  38. a.liuke-biaoqian.tag-link:last-child {
  39.     border-top-right-radius: 6px;
  40.     border-bottom-right-radius: 6px;
  41. }
  42. @media (hover: hover) {
  43.     .tag-container:hover {
  44.         box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  45.     }
  46.    
  47.     a.liuke-biaoqian.tag-link:hover {
  48.         opacity: 0.8;
  49.     }
  50. }

  51. a.liuke-biaoqian.tag-link i {
  52.     margin-right: 3px;
  53. }
  54. @media (max-width: 768px) {
  55.     a.liuke-biaoqian.tag-link {
  56.         font-size: 9px;
  57.         padding: 0 4px;
  58.     }
  59. }

  60. .forum-title {
  61.     position: relative;
  62.     padding-right: 80px;
  63. }
  64. .forum-title {
  65.     position: relative;
  66.     padding-right: 80px;
  67. }
  68. .forum-posts {
  69.     position: relative;
  70. }
  71. .plate-badge {
  72.     position: absolute;
  73.     top: 0;
  74.     left: 0;
  75.     background-color: #007bff;
  76.     color: white !important;
  77.     padding: 2px 5px;
  78.     font-size: 12px;
  79.     line-height: 1.2;
  80.     border-radius: 8px 0 8px 0;
  81.     display: flex;
  82.     align-items: center;
  83.     transition: all 0.3s ease;
  84.     overflow: hidden;
  85. }
  86. .plate-badge::before {
  87.     content: '';
  88.     position: absolute;
  89.     top: 0;
  90.     left: -100%;
  91.     width: 100%;
  92.     height: 100%;
  93.     background: rgba(255,255,255,0.3);
  94.     transition: all 0.3s ease;
  95. }
  96. .plate-badge:hover {
  97.     box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  98.     transform: translateY(-2px);
  99. }
  100. .plate-badge:hover::before {
  101.     left: 100%;
  102. }
  103. .plate-icon {
  104.     display: inline-flex;
  105.     align-items: center;
  106.     margin-right: 3px;
  107.     transition: transform 0.3s ease;
  108. }
  109. .plate-badge:hover .plate-icon {
  110.     transform: scale(1.1);
  111. }
  112. .plate-icon i {
  113.     font-size: 12px;
  114.     transition: color 0.3s ease;
  115. }
  116. .plate-name {
  117.     display: inline-block;
  118.     vertical-align: middle;
  119.     transition: color 0.3s ease;
  120. }
  121. .plate-badge:hover .plate-name,
  122. .plate-badge:hover .plate-icon i {
  123.     color: #f0f0f0;
  124. }
  125. .forum-posts.mini {
  126.     padding-top: 20px;
  127. }
  128. @media (max-width: 767px) {
  129.     .forum-posts.mini {
  130.         padding-top: 20px;
  131.     }
  132. }
  133. /*帖子左上角标识*/

  134. /*帖子标签*/
  135. /* 引入现代字体 */
  136. @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

  137. .tag-wrapper {
  138.     position: absolute;
  139.     right: 0;
  140.     top: 50%;
  141.     transform: translateY(-50%);
  142.     overflow: hidden;
  143.     white-space: nowrap;
  144.     transition: width 0.3s ease;
  145. }

  146. .tag-container {
  147.     display: inline-flex;
  148.     transition: transform 0.3s ease;
  149. }

  150. a.liuke-biaoqian.tag-link {
  151.     font-family: 'Roboto', sans-serif; /* 使用Roboto字体 */
  152.     font-size: 12px; /* 调整字体大小 */
  153.     padding: 2px 8px; /* 增加内边距 */
  154.     border-radius: 8px; /* 圆角边框 */
  155.     text-decoration: none;
  156.     margin-left: 6px; /* 增加外边距 */
  157.     display: inline-block;
  158.     transition: all 0.3s ease;
  159.     font-weight: 500;
  160.     line-height: 1.5; /* 调整行高 */
  161.     border: none;
  162.     outline: none !important;
  163.     opacity: 1;
  164.     visibility: visible;
  165.     background: linear-gradient(135deg, #6a82fb, #fc5c7d); /* 渐变背景色 */
  166.     color: #fff; /* 字体颜色 */
  167. }

  168. a.liuke-biaoqian.tag-link:hover {
  169.     transform: scale(1.1); /* 鼠标悬停时放大 */
  170. }

  171. a.liuke-biaoqian.tag-link i {
  172.     margin-right: 3px;
  173. }

  174. @media (max-width: 768px) {
  175.     a.liuke-biaoqian.tag-link {
  176.         font-size: 10px;
  177.         padding: 1px 4px;
  178.         margin-left: 4px;
  179.     }
  180. }


  181. /*帖子标签*/

  182. /* 新增高对比度板块颜色样式 */
  183. .plate-badge.plate-color-0 { background: linear-gradient(135deg, #6D8EFF 0%, #A6C1FF 100%) !important; } /* 浅蓝渐变 */
  184. .plate-badge.plate-color-1 { background: linear-gradient(135deg, #FF7E9F 0%, #FFB3C1 100%) !important; } /* 浅粉渐变 */
  185. .plate-badge.plate-color-2 {  background: linear-gradient(135deg, #0047AB 0%, #6B8CFF 100%) !important; } /* 深海钴蓝渐变(科技沉浸)*/
  186. .plate-badge.plate-color-3 {  background: linear-gradient(135deg, #00C9A7 0%, #70E0D6 100%) !important; }/*  松石绿*/
  187. .plate-badge.plate-color-10 { background: linear-gradient(135deg, #FFB347 0%, #FFD89C 100%) !important; } /* 浅橙渐变 */
  188. .plate-badge.plate-color-5 { background: linear-gradient(135deg, #66C2FF 0%, #A3D8FF 100%) !important; } /* 天蓝渐变115 */
  189. .plate-badge.plate-color-6 { background: linear-gradient(135deg, #7ED957 0%, #B4F0A7 100%) !important; } /* 苹果绿渐变 */
  190. .plate-badge.plate-color-7 { background: linear-gradient(135deg, #FF6B6B 0%, #FFA1A1 100%) !important; } /* 珊瑚红渐变*/
  191. .plate-badge.plate-color-8 { background: linear-gradient(135deg, #FF9F4D 0%, #FFC79E 100%) !important; } /* 蜜桃橙渐变 */
  192. .plate-badge.plate-color-9 { background: linear-gradient(135deg, #C77DFF 0%, #E5C2FF 100%) !important; } /* 浅紫渐变*/
  193. .plate-badge.plate-color-4 { background: linear-gradient(135deg, #FF5E84 0%, #FFB9C9 100%) !important; }/* 草莓粉 uc*/
  194. .plate-badge.plate-color-11 { background: linear-gradient(135deg, #FFD74D 0%, #FFE9A3 100%) !important; } /* 浅金渐变 */
  195. .plate-badge.plate-color-12 { background: linear-gradient(135deg, #C445F0 0%, #FF8DF5 100%) !important; } /* 霓虹紫渐变 */
  196. .plate-badge.plate-color-13 { background: linear-gradient(135deg, #FF7F32 0%, #FFC470 100%) !important; } /* 活力橙渐变*/
  197. .plate-badge.plate-color-14 { background: linear-gradient(135deg, #00E0D7 0%, #A4FFE8 100%) !important; } /* 荧光青渐变 */
复制代码
JS代码
将下面的代码放到子比主题–>>自定义JS样式即可!
  1. const tagColors = [
  2.    { bg: 'linear-gradient(135deg, #6a82fb, #fc5c7d)', textColor: '#ffffff' },
  3.     { bg: 'linear-gradient(135deg, #ff7e5f, #feb47b)', textColor: '#ffffff' },
  4.     { bg: 'linear-gradient(135deg, #23a6d5, #23d5ab)', textColor: '#ffffff' },
  5.     { bg: 'linear-gradient(135deg, #ff9966, #ff5e62)', textColor: '#ffffff' },
  6.     { bg: 'linear-gradient(135deg, #a1c4fd, #c2e9fb)', textColor: '#ffffff' },
  7.     { bg: 'linear-gradient(135deg, #ff5f6d, #ffc371)', textColor: '#ffffff' },
  8.     { bg: 'linear-gradient(135deg, #0093E9, #80D0C7)', textColor: '#ffffff' },
  9.     { bg: 'linear-gradient(135deg, #ff99cc, #b366cc)', textColor: '#ffffff' },
  10.     { bg: 'linear-gradient(135deg, #6dd5ed, #2193b0)', textColor: '#ffffff' },
  11.     { bg: 'linear-gradient(135deg, #f6d365, #fda085)', textColor: '#ffffff' },
  12.     { bg: 'linear-gradient(135deg, #74ebd5, #9face6)', textColor: '#ffffff' },
  13.     { bg: 'linear-gradient(135deg, #f093fb, #f5576c)', textColor: '#ffffff' },
  14.     { bg: 'linear-gradient(135deg, #a18cd1, #fbc2eb)', textColor: '#ffffff' },
  15.     { bg: 'linear-gradient(135deg, #e0c3fc, #8ec5fc)', textColor: '#ffffff' },
  16.     { bg: 'linear-gradient(135deg, #ff9a9e, #fad0c4)', textColor: '#ffffff' }
  17. ];

  18. let tagsInitialized = false;

  19. function applyRandomColor(tag) {
  20.    
  21.     if (tag.closest('.plate-badge')) return;
  22.    
  23.     if (tag.dataset.colorApplied) return;
  24.     const randomColor = tagColors[Math.floor(Math.random() * tagColors.length)];
  25.     tag.style.setProperty('background', randomColor.bg, 'important');
  26.     tag.style.setProperty('color', randomColor.textColor, 'important');
  27.     tag.dataset.colorApplied = 'true';
  28. }

  29. function setupTagDrawer() {
  30.     const tagWrappers = document.querySelectorAll('.tag-wrapper');
  31.     const isMobile = window.innerWidth <= 768;
  32.     const visibleTagCount = isMobile ? 2 : 3;

  33.     tagWrappers.forEach(wrapper => {
  34.         const container = wrapper.querySelector('.tag-container');
  35.         const tags = container.querySelectorAll('a.liuke-biaoqian.tag-link');
  36.         
  37.         if (!tagsInitialized) {
  38.             tags.forEach(applyRandomColor);
  39.         }
  40.         

  41.         setTimeout(() => {
  42.             const visibleTags = Array.from(tags).slice(0, visibleTagCount);
  43.             const initialWidth = visibleTags.reduce((sum, tag) => sum + tag.offsetWidth + 6, 0);
  44.             const fullWidth = Array.from(tags).reduce((sum, tag) => sum + tag.offsetWidth + 6, 0);
  45.             
  46.             wrapper.style.width = `${initialWidth}px`;
  47.             
  48.             wrapper.addEventListener('mouseenter', () => {
  49.                 wrapper.style.width = `${fullWidth}px`;
  50.             });

  51.             wrapper.addEventListener('mouseleave', () => {
  52.                 wrapper.style.width = `${initialWidth}px`;
  53.             });
  54.         }, 100);
  55.     });
  56.    
  57.     tagsInitialized = true;
  58. }

  59. function initializeTags() {
  60.     setTimeout(setupTagDrawer, 100);
  61. }

  62. function applyTagEffects() {
  63.     const tags = document.querySelectorAll('a.liuke-biaoqian.tag-link');
  64.     tags.forEach(applyRandomColor);
  65.     initializeTags();
  66. }
  67. document.addEventListener('DOMContentLoaded', function() {
  68.     applyTagEffects();
  69.     document.addEventListener('ajaxComplete', function(event) {
  70.         applyTagEffects();
  71.     });
  72.     const observer = new MutationObserver((mutations) => {
  73.         let tagsAdded = false;
  74.         mutations.forEach((mutation) => {
  75.             if (mutation.type === 'childList') {
  76.                 mutation.addedNodes.forEach((node) => {
  77.                     if (node.nodeType === Node.ELEMENT_NODE) {
  78.                         if (node.matches('a.liuke-biaoqian.tag-link')) {
  79.                             tagsAdded = true;
  80.                         } else if (node.querySelector('a.liuke-biaoqian.tag-link')) {
  81.                             tagsAdded = true;
  82.                         }
  83.                     }
  84.                 });
  85.             }
  86.         });
  87.         if (tagsAdded) {
  88.             applyTagEffects();
  89.         }
  90.     });
  91.     const config = { childList: true, subtree: true };
  92.     if (document.body) {
  93.         observer.observe(document.body, config);
  94.     } else {
  95.         console.warn('document.body is not available yet.');
  96.     }
  97. });
  98. window.addEventListener('load', function() {
  99.     setTimeout(setupTagDrawer, 100);
  100. });
  101. window.addEventListener('resize', setupTagDrawer);
  102. const style = document.createElement('style');
  103. style.textContent = `
  104.     a.liuke-biaoqian.tag-link {
  105.         transition: background 0.3s ease, color 0.3s ease;
  106.         opacity: 0;
  107.         animation: fadeIn 0.3s ease forwards;
  108.     }
  109.     @keyframes fadeIn {
  110.         to { opacity: 1; }
  111.     }
  112. `;
  113. document.head.appendChild(style);
复制代码

本帖被以下淘专辑推荐:

路虽远,行则将至;事虽难,做则必成。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

飞流广播+ 发布

07-23 18:52
飞流这论坛到底有没有资本给我投资一下啊!
07-20 22:07
系统消息:飞流安卓客户端APP已上线,请在QQ群(123129)群文件内获取下载。
02-21 02:22
01-24 12:40
站内通告

📢 六月份后均不在线,请悉知

提供资源交易、信息共享、靓号交流、技术变现、学习问答、兴趣娱乐等全面服务。

1.丰富功能系统,扩展社区特色玩法,打造最好的互联网聚集圈子。

2.准确信息真实交易,安全快捷又方便,让虚拟交易面对面。

3. 天上不会掉馅饼,话术骗术迷人心,切勿脱离平台线下交易,被骗与平台无关!

4. 欺诈骗钱,违规违法将视情受到警告&禁言&封号甚至检举至👮🏻‍♀️处理!

官方Q群:1003810038钉推群:BAYR2383 站长QQ:3388700000

飞流论坛(FLLT.CN),一个专注于资源信息发布、虚拟网络交易、技术学习与娱乐社交的交流平台。
  • 钉钉新帖推送群
  • 官方交流QQ群
  • 站长唯一微信号

💥客户端|🧿小黑屋|📴手机页|飞流网 |网站地图

GMT+8, 2026-9-14 10:50 , Processed in 0.058479 second(s), 65 queries, MemCached On , Gzip On.

飞流论坛 HanAnalytics icp

Copyright © 2024-2026 飞流网 版权所有 All Rights Reserved. X3.5

快速回复 返回顶部 返回列表