详情 评论 问答 WordPress论坛子比主题美化-zibll官网添加一个灵动岛样式美化代码小柚子3月15日更新关注私信02179 WordPress论坛子比主题美化-zibll官网添加一个灵动岛样式美化代码 本次教程适合子比主题!其他主题自测 教程1 将下面代码添加到自定义css中 .dynamic-island:hover img {width:30px; height:30px;;} .bars {display:flex;align-items:center; justify-content:flex-end; gap:3px;} .bar {width:2px;height:13px;background-color:green;animation:bounce 1s infinite ease-in-out;animation-direction:alternate;} .bar:nth-child(1) {animation-duration:1s;} .bar:nth-child(2) {animation-duration:0.9s;} .bar:nth-child(3) {animation-duration:0.8s;} .bar:nth-child(4) {animation-duration:0.7s;} .bar:nth-child(5) {animation-duration:0.6s;} .bar:nth-child(6) {animation-duration:0.9s;} .bar:nth-child(7) {animation-duration:0.7s;} .dynamic-island {position:fixed;top:80px;left:50%;transform:translateX(-50%) scale(0); transform-origin:center;width:auto;max-width:80%;height:40px;background-color:#000;border-radius:25px; color:white;display:flex;align-items:center;justify-content:space-between; transition:transform 0.4s ease-in-out,height 0.6s ease-in-out,border-radius 0.6s ease-in-out,box-shadow 0.5s ease-in-out,opacity 0.5s ease-in-out;overflow:visible; z-index:1000;padding-left:35px; padding-right:20px; opacity:0;box-shadow:0 0px 10px rgba(0,0,0,0.45);;} .dynamic-island.active {transform:translateX(-50%) scale(1); opacity:1;} .dynamic-island.inactive {transform:translateX(-50%) scale(0); opacity:0;} .island-content {opacity:0;transition:opacity 0.9s ease-in-out,filter 0.8s ease-in-out; font-weight:bold; flex-grow:1; text-align:right; width:100%;} .dynamic-island.active .island-content {opacity:1;} .dynamic-island img {position:absolute;left:10px; width:20px; height:20px; object-fit:cover; transition:height 0.8s ease-in-out,width 0.8s ease-in-out,filter 0.8s ease-in-out;} .dynamic-island:hover {height:60px;border-radius:50px;} @keyframes bounce {0% {transform:scaleY(0.3);background-color:green;} 50% {transform:scaleY(1);background-color:orange;} 100% {transform:scaleY(0.3);background-color:green;} ;} 将下面代码添加到后台自定义头部html <div class="dynamic-island inactive" id="dynamicIsland" style="opacity: 0;"> <img src="https://img.alicdn.com/imgextra/i1/2210123621994/O1CN01lajerM1QbIl9aoHcJ_!!2210123621994.png" alt="通知图标" width="30" height="30"> <div class="island-content"> <div class="bars" style="line-height: 50px; margin: 0;"> <p style="line-height: 50px; margin: 0; font-size: 12px; padding-right: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;"> 欢迎访问斗罗大陆网博客</p> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> </div> </div> </div> 将下面代码添加到zibll文件夹中的function.php或func.php文件中 // 灵动岛 function add_dynamic_island_script() { ?> <script type="text/javascript"> window.onload = function() { // 触发灵动岛的显示 triggerIsland(); // 获取当前页面的标题 let title; const currentUrl = window.location.pathname; // 获取当前 URL 路径 if (currentUrl.includes('/message/')) { // 如果访问了消息页面 document.querySelector('.bars p').innerText = "正在访问消息页面"; } else if (currentUrl.includes('/user/')) { // 如果访问了用户中心页面 document.querySelector('.bars p').innerText = "欢迎来到用户中心"; } else if (document.body.classList.contains('home') || document.body.classList.contains('front-page')) { // 如果是首页 document.querySelector('.bars p').innerText = "欢迎来到斗罗大陆网博客"; } else if (document.body.classList.contains('single')) { // 如果是单篇文章 title = "<?php echo addslashes(html_entity_decode(get_the_title())); ?>"; // 获取文章标题并解码 document.querySelector('.bars p').innerText = "正在访问:" + title; } else if (document.body.classList.contains('category')) { // 如果是分类页面 const category = "<?php echo addslashes(html_entity_decode(get_queried_object()->name)); ?>"; // 获取当前分类的名称 document.querySelector('.bars p').innerText = "正在访问:" + category + " 分类"; } else if (document.body.classList.contains('page')) { // 如果是单个页面 title = "<?php echo addslashes(html_entity_decode(get_the_title())); ?>"; // 获取页面标题并解码 document.querySelector('.bars p').innerText = "正在访问:" + title; } else { // 如果以上都不匹配,可以使用默认值 document.querySelector('.bars p').innerText = "欢迎来到斗罗大陆网博客"; } } ; // 触发灵动岛的显示 function triggerIsland() { const island = document.getElementById('dynamicIsland'); if (island) { island.style.opacity = 1; island.classList.add('active') island.classList.remove('inactive'); // 在4秒后触发关闭动画 setTimeout(() => { closeIsland(); } , 4000); } } function closeIsland() { const island = document.getElementById('dynamicIsland') if (island) { island.classList.remove('active'); island.classList.add('inactive'); setTimeout(() => { island.style.opacity = 0; // 使灵动岛透明 } , 600); // 与 transform 动画持续时间一致 } } </script> <?php } add_action('wp_head', 'add_dynamic_island_script'); 文章很赞,支持一下吧~ 还没有人为TA充电 为TA充电 还没有人为TA充电 © 版权声明 版权声明 1 本站名称: 七九网单 2 本站网址:www.fengxue.cc 3 本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长进行删除处理。 4 本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。 5 本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报。 6 本站附件资源、教程等内容如因时效原因失效或不可用,请评论区留言或联系站长及时更新。 THE ENDWordPress主题子比美化 喜欢就支持一下吧点赞9打赏 分享QQ空间微博QQ好友复制链接收藏如何下载资源?您可以通过搜索或浏览分类列表来找到您期望下载的资源。随后点击资源介绍页右侧的下载链接按钮,依据提示信息进行操作即可。是否需要充值才能下载?大部分资源可积分免费下载,为了维持网站的运行小部分资源须付费才能下载。下载的资源是否有版权?本站提供的下载资源均为网络搜集,仅供个人学习和交流使用。对于版权问题,请用户自行判断并承担相应责任。 上一篇 子比主题插件–TikTok/抖音登录插件 下一篇 zibll子比主题美化官网-WordPress博客底部横向网站信息统计模块美化 评论 抢沙发 请登录后发表评论 登录 注册 暂无评论内容