壹影博客.
我在下午4点钟开始想你
Js返回顶部可爱宠物代码分享
  • 2021-4-26日
  • 0评论
  • 2897围观

Js返回顶部可爱宠物代码分享

本页下滑可查看效果

  var hm = document.createElement("style");hm.innerHTML = `@media (max-width:1000px) {.back-to-top {z-index:9999!important;right:30px!important;transition:all .5s ease-in-out!important;-webkit-animation:float 2s linear infinite!important;animation:float 8s linear infinite!important;}} @keyframes float{0%{transform:translatey(0px);transform:translatex(0px)}50%{transform:translatey(-30px);transform:scale(0.95,0.95)}100%{transform:translatey(0px);transform:translatex(0px)}}.back-to-top{cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0);position:fixed;right:70px;top:-900px;z-index:9999;width:70px;height:900px;background:url(https://bk.yyge.net/%E6%B5%8B%E8%AF%95/top/top.png);transition:all .5s ease-in-out;-webkit-animation:float 2s linear infinite;animation:float 8s linear infinite;opacity:1}@media screen and (max-width:999px){.mobile{display:block!important}}`;
  var s = document.getElementsByTagName("title")[0];s.parentNode.insertBefore(hm, s);var elscript = document.createElement("div");elscript.setAttribute("class","back-to-top");document.body.appendChild(elscript);
function loadJs(path,callback){var header=document.getElementsByTagName("head")[0];var script=document.createElement('script');script.setAttribute('src',path);header.appendChild(script);
 if(!false){script.onload=function(){callback();}}else{script.onreadystatechange=function(){if(script.readystate=="loaded" ||script.readState=='complate'){callback();}}};}
loadJs("https://bk.yyge.net/%E6%B5%8B%E8%AF%95/top/jquery-3.3.1.min.js",function(){completed();});
function completed() {$(function() {$(window).scroll(function() {var scroHei = $(window).scrollTop();if (scroHei > 500) {$('.back-to-top').css('top','-280px');} else {$('.back-to-top').css('top','-999px');}});$('.back-to-top').click(function() {$('body,html').animate({scrollTop: 0}, 200);});})}

 Js插件参数

 适用平台:手机 & 电脑
 收费状态:免费调用
 环境状态:依赖JQuery
 插件大小:约2.58kb
 是否加密:

发表评论

渝ICP备19011465号 | 渝ICP备19011465号-1