PHP函数里面写JQ CSS HTML的写法案例

复制代码
/**
 * @description: 返回顶部
 * @param {*}
 * @return {*}
 */
php 复制代码
public function gotop()
{
    global $_L, $COMCFG;
    $plugin = $COMCFG['plugin']['gotop'] ?: [];
    $plugin = array_merge([
        "right"   => 30,
        "bottom"  => 80,
        "color"   => "rgba(255, 255, 255, 1)",
        "bgcolor" => "rgba(96, 98, 102, 1)",
    ], $plugin);
    if ($plugin['style'] == "1" && $plugin['image']) {
        $css  = '<style>.lcms-gotop-Box{display:none;position:fixed;width:50px;height:auto;right:' . $plugin['right'] . 'px;bottom:' . $plugin['bottom'] . 'px;cursor:pointer;z-index:999}.lcms-gotop-Box img{display:block;width:100%;vertical-align:middle}</style>';
        $html = '<div class="lcms-gotop-Box"><img src="' . oss($plugin['image']) . '" alt="GOTOP" title="GOTOP"/></div>';
    } else {
        $css  = '<style>.lcms-gotop-Box{display:none;position:fixed;width:40px;height:40px;line-height:40px;right:' . $plugin['right'] . 'px;bottom:' . $plugin['bottom'] . 'px;text-align:center;color:' . $plugin['color'] . ';background:' . $plugin['bgcolor'] . ';cursor:pointer;box-shadow:0 0 1px 1px #fff;z-index:999}.lcms-gotop-Box i{font-size:20px;vertical-align:middle}</style>';
        $html = '<div class="lcms-gotop-Box"><i class="fas fa-chevron-up"></i></div>';
    }
    echo "LCMSJQ('body').append('{$css}').append('{$html}');";
    echo 'if(LCMSJQ(".lcms-gotop-Box").length>0){LCMSJQ(window).scroll(function(){if(LCMSJQ(this).scrollTop()>100){LCMSJQ(".lcms-gotop-Box").fadeIn()}else{LCMSJQ(".lcms-gotop-Box").fadeOut()}});LCMSJQ(".lcms-gotop-Box").click(function(){LCMSJQ("html ,body").animate({scrollTop:0},300);return false});}';
}
相关推荐
里欧跑得慢41 分钟前
CSS 模块化架构的演进:BEM、CSS Modules 到 CSS-in-JS 的反思
前端·css·flutter·web·css-in-js
2601_965798472 小时前
Salient Theme Setup Guide for Fast Creative WordPress Sites
数据库·web3·php·wordpress
DS随心转插件5 小时前
Grok生成的html怎么导出——AI导出鸭:大模型结构化输出的“最后一公里”工程化解构
前端·人工智能·ai·html·豆包·deepseek·ai导出鸭
人间凡尔赛5 小时前
2026 前端必修:4 个让 CSS 脱胎换骨的现代新特性(附实战代码)
前端·css
xixiaoyunya8 小时前
中小微企业轻量组网方案的技术选型与实践:从传统专线到软定义隧道的成本与效能分析
服务器·php·apache
知行产研9 小时前
中国矿山无人驾驶出海的三重门
数据库·mysql·php
前进的程序员11 小时前
告别Copilot?Codex本地化部署指南
开源·php·copilot·codex
weixin_BYSJ198711 小时前
springboot智慧公共交通系统---附源码51123
java·javascript·spring boot·python·django·flask·php
01_ice12 小时前
html个人简历展示
前端·html
外滩运维专家1 天前
通配符证书到期,阿里云上几个服务的证书怎么一次换完
运维·开发语言·nginx·https·php·消息推送