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});}';
}
相关推荐
Cyber4K7 小时前
【Python专项】进阶语法-系统资源监控与数据采集(1)
开发语言·python·php
Le_ee7 小时前
ctfweb:php/php短标签/.haccess+图片马/XXE
开发语言·前端·php
爱上好庆祝7 小时前
学习js的第七天(wed APIs的开始)
前端·javascript·css·学习·html·css3
gogoing9 小时前
CSS 属性值计算过程(Computed Value)
前端·css
Johnstons13 小时前
Wireshark 和 tcpdump 到底怎么选?网络故障排查实战中的边界、判断标准与落地清单
wireshark·php·es·tcpdump·抓包分析·抓包与协议分析工具选型
ZC跨境爬虫14 小时前
跟着 MDN 学 HTML day_36:(深入理解 Comment 接口与 DOM 注释节点)
前端·javascript·ui·html·音视频·视频编解码
暮雨疏桐14 小时前
阿里云从 OSS 将 CSV 推送至内网机器方案
阿里云·云计算·php
laomocoder16 小时前
Project-Nexus-WAN-跨公网Agent对话
开发语言·php
2301_8156453816 小时前
css基础
前端·css
ZC跨境爬虫17 小时前
跟着 MDN 学 HTML day_34:(深入XML 中的 CDATASection 接口)
xml·前端·html·html5·媒体