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});}';
}
相关推荐
程序员大阳10 小时前
HTML+CSS+JS对话式实战(5)-活动管理页之查看报名名单的实现
javascript·css·html·查看报名名单
曦樂~10 小时前
【Web Development】02 CSS
前端·css
东鹏特饮11 小时前
经典打砖块(Breakout)游戏
前端·css·css3
reasonsummer19 小时前
【教学类-150-03】20261108蝴蝶连连看html(一页2个版面、3个版面)
python·html
爱和冰阔落21 小时前
【Linux网络】JsonCpp 怎么实现序列化?从 Request/Response 到网络计算器消息设计
linux·运维·网络·php
eggwyw21 小时前
PHP8.5怎么用ffmpeg提取视频里的字幕轨道
开发语言·php
我叫黑大帅1 天前
PHP 常驻 Worker 中 MySQL 连接中断问题报告
后端·面试·php
程序员大阳1 天前
HTML+CSS+JS对话式实战(9)-项目总结与问题分析
javascript·css·html·实战·项目总结
国科安芯2 天前
人在回路中的总线:商业空间站环境控制与生命保障系统CANFD网络的可靠性与功能安全
网络·嵌入式硬件·安全·架构·php·抗辐射
程序员大阳2 天前
HTML+CSS+JS对话式实战(6)-学生端查看活动功能开发
javascript·css·html·模块·查看学生