Warning: Undefined array key "night" in /www/wwwroot/dhaomu.com/wp-content/themes/b2/header.php on line 18

仿哔哩哔哩网站页面回顶部的火箭

仿哔哩哔哩网站页面回顶部的火箭。如果您是子主题用户,您可以将代码放在后台子主题设置->基本设置->插入代码的菜单中
仿哔哩哔哩网站页面回顶部的火箭插图
仿哔哩哔哩网站页面回顶部的火箭

html代码

<div class="to-top"></div>

css代码

/*小火箭*/

.to-top {
    position: fixed;
    display: none;
    bottom: 100px;
    right: 20px;
    width: 62px;
    height: 85px;
    cursor: pointer;
    background-image: url(图片地址);
    background-position: -40px -44px;
    transition: transform 0.3s ease-in;
    transform: translateY(0);
    z-index: 999;
}
.to-top:hover {
            animation: up-top .4s steps(1) infinite;
        }
.to-top.fly {
    transform: translateY(-1000px);
}
@keyframes up-top{
    0% {
                background-position-x: -40px;
    }
    16.5% {
                background-position-x: -183px;
    }
    33% {
                background-position-x: -326px;
    }
    49.5% {
                background-position-x: -469px;
    }
    66% {
                background-position-x: -612px;
    }
    82.5% {
                background-position-x: -755px;
    }
    100% {
                background-position-x: -40px;
    }
}

JS代码

function toggleToTopVisibility() {
    if ($(window).scrollTop() > 0) {
        $(".to-top").fadeIn(100);
    } else {
        $(".to-top").fadeOut(100);
    }
}

toggleToTopVisibility();

$(".to-top").click(function() {
    $(this).addClass("fly");
    setTimeout(() => {
        $(this).removeClass("fly");
    }, 300);
    $("html, body").animate({ scrollTop: 0 }, "fast");
});

$(window).scroll(toggleToTopVisibility);

图片地址:https://img.dhaomu.com/uploads/2024/06/e5e99d3fef2abb380cfc2f255d4719de.png

如果您是子主题用户,您可以将代码放在后台子主题设置->基本设置->插入代码的菜单中

温馨提示:
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:duhaomu@163.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明

给TA赞赏
共{{data.count}}人
人已赞赏
编程技巧

Java技术版本的mbstrwidth

2023-11-3 0:00:00

编程技巧

Wordpress主题美化7B2主题美化给B2主题增加FancyBox灯箱

2024-1-30 9:14:00

0 条回复 A文章作者 M管理员

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914
----《》
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索