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});}';
}
相关推荐
anOnion10 小时前
构建无障碍组件之Slider Pattern
前端·html·交互设计
printfLILEI11 小时前
php中的类与对象以及反序列化
linux·开发语言·php
华科大胡子11 小时前
AI开发者的网络卡点:Anthropic连接超时
开发语言·php
bill328227804313 小时前
AE 的 Animation Composer 描边动效玩法 + 极简 MG 制作流程(含示例)
php·composer
就叫_这个吧14 小时前
HTML常用标签及举例使用
前端·html
csdn_aspnet15 小时前
PHP 算法 LeetCode 编号 70 - 爬楼梯
算法·leetcode·php
林熙蕾LXL16 小时前
socket编程-TCP开发常用函数
网络协议·tcp/ip·php
m0_7381207216 小时前
渗透测试基础——黑盒测试下的Web漏洞挖掘与利用解析(一)
服务器·前端·网络·安全·php
要写代码18 小时前
2026-Css忘掉一切、归零再启
css
就叫_这个吧19 小时前
JavaScript中常用事件示例展示附源码
开发语言·javascript·html