zoukankan
html css js c++ java
回到顶部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> <title>回到顶部 - 豪情</title> <style type="text/css"> *{ margin:0; padding:0;} body{font:12px/1.125 Arial,Helvetica,sans-serif;background:#fff;} a:focus,input,textarea{outline-style:none;} a{color:#0a8cd2;text-decoration:none;} a:hover{text-decoration:underline;} .none{display:none} .demo{ height:2000px;} .gotop{ 18px;line-height:1.2;padding:7px 0px 7px 2px;background-color:#000;color:#fff;font-size:12px;text-align:center;position:fixed;_position:absolute;right:0px;bottom:100px;_bottom:"auto";cursor:pointer;opacity:0.6;filter:Alpha(opacity=60);border-radius:5px 0 0 5px; display:none;} .gotop:hover{ text-decoration:none;opacity:0.7;filter:Alpha(opacity=70);} </style> </head> <body> <div class="demo"></div> <script type="text/javascript"> (function(){ function viewSize(){ var doc = document, de = doc.documentElement; return { 'width': (window.innerWidth || (de && de.clientWidth) || doc.body.clientWidth), 'height': (window.innerHeight || (de && de.clientHeight) || doc.body.clientHeight) }; } function getScrollTop(){ return document.documentElement.scrollTop || document.body.scrollTop; } var btn = null, timer = 0; function apendScroll(){ btn = document.createElement('a'); btn.href = 'javascript:void(0)'; btn.className = 'gotop'; btn.innerHTML = '回到顶部'; document.body.appendChild(btn); } apendScroll(); function ie6Top(){ if(!window.XMLHttpRequest){ btn.style.top = getScrollTop() + viewSize().height - 200 + 'px'; } } window.onscroll = function(){ btn.style.display = getScrollTop() > 0 ? 'block' : 'none'; ie6Top(); } btn.onclick = function(){ timer = setInterval(function(){ var scrollTop = getScrollTop(); var iSpeed = Math.floor(- scrollTop / 8); if(scrollTop == 0){ clearInterval(timer); } ie6Top(); document.documentElement.scrollTop = document.body.scrollTop = scrollTop + iSpeed; }, 30); } }()); </script> </body> </html>
运行代码
查看全文
相关阅读:
容斥原理解决某个区间[1,n]闭区间与m互质数数量问题
Educational Codeforces Round 28
括号匹配问题(区间dp)
小球装箱问题八连(组合数学)
Educational Codeforces Round 29
Codeforces Round #437 (Div. 2, based on MemSQL Start[c]UP 3.0
Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)
Opencv保存读取float类型深度图
OpenGL快速入门
使用selenium判断标签的元素值是否存在
原文地址:https://www.cnblogs.com/jikey/p/2980351.html
最新文章
图例解析JDK,JRE,JVM概念及使用
啊D网络工具包
御剑后台扫描珍藏版
专杀工具+特定病毒的终结者
Visual C++ Runtime Library
IP雷达4.0+网络检测
Win 定时关机
十天学会易语言图解教程+快速入门
美图秀秀美化版
路由器设置详细指导
热门文章
运用 node + express + http-proxy-middleware 实现前端代理跨域的 详细实例哦
vue相关
rem js 自适应布局
windows 终端命令详解
函数提升和变量提升,以及他们的优先级
使用MongoVUE
匿名函数 声明函数 和 箭头函数
Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)
Codeforces Round #429 (Div. 2)
Uva10917 Walk Through the Forest
Copyright © 2011-2022 走看看