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});}';
}
相关推荐
我要让全世界知道我很低调34 分钟前
记一次 Vite 下的白屏优化
前端·css
again4323 小时前
css生效规则
css
不吃肉的羊3 小时前
PHP设置文件上传最大值
后端·php
Esun_R3 小时前
使用CSS选择器选择列表中最后一个子元素的几种情况
css
iphone1083 小时前
一次编码,多端运行:HTML5多终端调用
前端·javascript·html·html5
海底火旺4 小时前
以一个简单的React应用理解数据绑定的重要性
前端·css·react.js
Allen Bright6 小时前
【CSS-15】深入理解CSS transition-duration:掌握过渡动画的时长控制
前端·css
一天睡25小时7 小时前
一款减轻前端图片命名工作量的图片转换器
前端·javascript·html
梅纳德7 小时前
如何发现一个网站的全部页面?7种方法
html
一只小风华~10 小时前
Web前端开发: :has功能性伪类选择器
前端·html·html5·web