网站添加灵动岛美化样式&WordPress插件 图标

网站添加灵动岛美化样式&WordPress插件

1260 次浏览 分类:网站模板
分类
收录时间
2026-02-18 01:12

数据统计

1260 浏览量
0 评论数
2026-02-18 收录时间
2026-02-17 更新时间

一、简介

这是一款模仿苹果灵动岛的一个样式代码,每刷新一次页面,都会通过灵动岛显示页面标题。

二、效果

图片[1]-网站添加灵动岛美化样式&WordPress插件-聆风小站

三、代码部署

1、css代码

<!-- 灵动岛CSS 开始 --><style type="text/css">.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);    flex: 1; /* 使宽度自动扩展 */    white-space: nowrap; /* 防止文字换行 */}.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: left; /* 文字左对齐 */    margin-left: 10px; /* 与图片留出空间 */    overflow: hidden; /* 防止溢出 */    text-overflow: ellipsis; /* 溢出显示省略号 */}.dynamic-island.active .island-content {    opacity: 1;}.dynamic-island img {    position: absolute;    left: 5px; /* 调整图片位置 */    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;}.dynamic-island:hover img {    width: 30px;    height: 30px;}.bars {    display: flex;    align-items: center;    justify-content: flex-end;    gap: 3px;    min-width: 40px; /* 最小宽度限制 */}.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;}@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;    }}</style><!-- 灵动岛CSS 结束 -->

2、html代码

<!-- 灵动岛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><!-- 灵动岛HTML 结束 -->

3、js代码

// 灵动岛JS 放子比functions.php 开始function add_dynamic_island_script() {    ?>    <script type="text/javascript">    window.onload = function() {        // 触发灵动岛的显示        triggerIsland();        // 获取当前页面的标题        let title;        // 获取当前 URL 路径        const currentUrl = window.location.pathname;                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 = "欢迎来到:" + <?php echo json_encode(get_bloginfo('name')); ?>;        } else if (document.body.classList.contains('single')) {            // 文章页面,获取文章标题            title = <?php echo json_encode(html_entity_decode(get_the_title())); ?>;            document.querySelector('.bars p').innerText = "正在访问:" + title;        } else if (document.body.classList.contains('category')) {            // 分类页面,获取当前分类的名称            const category = <?php echo json_encode(html_entity_decode(get_queried_object()->name ?? '')); ?>;            document.querySelector('.bars p').innerText = "正在访问:" + category + " 分类";        } else if (document.body.classList.contains('page')) {            // 单个页面,获取页面标题并解码            title = <?php echo json_encode(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');            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);        }    }    </script>    <?php}add_action('wp_head', 'add_dynamic_island_script');// 灵动岛JS 放子比functions.php 结束

四、WP插件

由于js代码要修改主题文件,为防止因主题更新导致样式失效,将此代码整合为WordPress插件形式,直接安装启动即可使用。


wordpress定制软件游戏下载主题!价值3000+免费分享 图标

wordpress定制软件游戏下载主题!价值3000+免费分享

wordpress定制软件游戏下载主题!价值3000+免费分享私人定制模板,6天上权3,原创定制内含手机,电脑模板,打包全部程序+数据这个站点好久没管了,域名也卖了,数据也不要了,大家自由发挥吧!移动端问题1、首先绑定移动端域名,并且解析,如果www有ssl,移动端也必须要有。2、添加代码:在文件底部获取当前访问的域名$home&nbsp;=&nbsp;&#39;http://&#39;.$_SERVER[&#39;HTTP_HOST&#39;];$siteurl&nbsp;=&nbsp;&#3
wordpress定制软件游戏下载主题!价值3000+免费分享  图标

wordpress定制软件游戏下载主题!价值3000+免费分享

私人定制模板,6天上权3,原创定制内含手机,电脑模板,打包全部程序+数据这个站点好久没管了,域名也卖了,数据也不要了,大家自由发挥吧!移动端问题1、首先绑定移动端域名,并且解析,如果www有ssl,移动端也必须要有。2、添加代码:在文件底部获取当前访问的域名$home = &#39;http://&#39;.$_SERVER[&#39;HTTP_HOST&#39;];$siteurl = &#39;http://&#39;.$_SERVER[&#39;HTTP_HOST&#39;];define
全解密最新苹果CMS海螺模版V20源码 加广告代码 图标

全解密最新苹果CMS海螺模版V20源码 加广告代码

&lt;已去除SG11加密!!!注意是全解密!任何加密已去除,上线之前请运行一下修复多线路时播放页列表点其他线路还是播放默认线路的问题修复前台黑白切换和字体颜色切换失效修复微信二维码没有对接苹果控制后台问题优化换一换功能的图片加载速度修复PC页面下滑空白问题修复播放页列表不能滑动问题修复换一换失效分享无链接问题修复页面下拉时顶部导航透明化修复播放列表点击排序不能切换正序倒序修复赞赏二维码且调用后台设置使用说明:上传模板至template目录内主题设置后台:– 后台快捷菜单配置添加– 海螺主题设置
子比主题-防红插件 图标

子比主题-防红插件

MS防红插件是一款面向 WordPress 网站的防红辅助插件,主要用于在微信、QQ、抖音等平台访问网站链接时,提供更友好的跳转处理,减少链接被拦截、打不开或访问体验不佳的问题。主要功能1. 支持微信、QQ、抖音等常见平台的防红跳转处理。2. 可用于网站链接分享、文章推广、活动页面分发等场景。3. 提供防 iframe 嵌入能力,减少网站页面被第三方页面恶意嵌套。4. 独立插件形式运行,安装启用后可在后台进行相关设置。5. 后台使用 CSF 设置界面,操作简单,适合普通站长使用。插件演示图&nb
子比主题-邮件提醒插件 图标

子比主题-邮件提醒插件

子比邮件提醒插件是一款面向 WordPress + Zibll&nbsp;子比主题站点的消息通知工具。它可以在文章首次发布、已发布文章内容更新、用户登录成功等关键动作发生时,自动发送邮件提醒,并可结合 Zibll 主题自带的站内消息能力,把重要动态同步推送给站内用户或管理员。&nbsp;百度网盘:&nbsp;https://pan.baidu.com/s/1aWVl20RScol_qW8JZY-2wg?pwd=n4nx&nbsp;提取码: n4nx
全新RIPro主题美化高端设计素材视频资源下载子主题源码模板RIPro 图标

全新RIPro主题美化高端设计素材视频资源下载子主题源码模板RIPro

简介:店主亲测搭配ripro9.0以及9.1版本可用,拿到源码发现有点小问题,店主已经。修改过了,直接下单领取安装即可!此美化包无授权无暗链,无需修改原主题代码,使用本美化包前请先下载最新RIPro主题,本子主题仅支持RiPro8.0以上版本,建议使用官方正版主题。更新日志:美化网站整站主色调颜色,优化代码结构,更适合SEO新增菜单顶部黑条,可设置多个瞄点跳转(后台自由编辑新增搜索条模块,可设置动态标题,热门标签(后台自由编辑)新增公告统计模块,样式美化(后台自由编辑)新增四栏展示模块,热门关键
仿3500游戏源码大气H5游戏门户网站模板源码_帝国CMS 图标

仿3500游戏源码大气H5游戏门户网站模板源码_帝国CMS

帝国 CMS7.5 仿《3500 游戏》源码,大气H5 游戏门户网站模板,H5 游戏在线网站源码;价值几百元的帝国 CMS H5 游戏模板。带移动端同步生成插件,同步生成手机站。可以做个在线游戏平台,还可以做少量大型游戏的推广平台,这类型的广告费都是很可观的,一般游戏平台流量都还可以,有需要的用户自行下载研究。下载地址
评论
还没有评论,来发表第一条吧。
发表评论