返回顶部特效(立即中断)
来源:互联网 发布:python 内存地址 编辑:程序博客网 时间:2024/06/01 08:50
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
}
div {
background-color:#7FFFD4;
height: 3000px;
width: 100%;
}
a {
-webkit-box-sizing: border-box;
display: none;
height: 50px;
width: 50px;
position: fixed;
right: 50px;
bottom: 50px;
color: #7FFFD4;
background-color: #FAEBD7;
text-align: center;
padding-top: 14px;
cursor: pointer;
}
</style>
<script>
window.onload = function() {
var timer;
// 计时器
var stop=true;
window.onscroll = function() {
var botton = document.getElementById("botton");
var canheght = document.documentElement.clientHeight;
var cantop = document.body.scrollTop;
if (canheght < cantop) {
botton.style.display = "block";
} else {
botton.style.display = "none";
}
if (!stop) {
clearInterval(timer);
}
stop=false;
}//这个判断用于确定滚动是否收到外力影响,timer计时器每次都能重新将stop重置为true
botton.onclick = function() {
timer = setInterval(function() {
var top = document.body.scrollTop;
var speed=top/5;
document.body.scrollTop = top-speed;
stop=true;
if (top == 0) {
clearInterval(timer);
}
}, 30);
}
}
</script>
</head>
<body>
<div></div>
<a id="botton">向上</a>
</body>
</html>
0 0
- 返回顶部特效(立即中断)
- jquery 返回顶部按钮特效
- 网页返回顶部js特效
- jquery实现返回顶部特效
- jquery返回顶部简单特效
- 滚动返回页面顶部的JS特效
- jquery的知识点----scrollTop()返回顶部特效
- jQuery返回顶部特效,网页右下角的回到顶部按钮
- JQuery 动画卷页 返回顶部 动画特效(兼容Chrome)
- 一款Jquery实现非常实用的返回浏览器顶部特效
- jquery 返回顶部(插件)
- 返回顶部
- 返回顶部
- 返回顶部
- 返回顶部
- 返回顶部
- 返回顶部
- 返回顶部
- iOS中的NSURLProtocol
- ElasticSearch简单查询
- 轮播图特效
- java嵌套类(Nested Classes)总结
- java几行代码搞定算术表达式的计算
- 返回顶部特效(立即中断)
- javascript - 常用互动 innerhtml className display class
- 1+1<<1+1优先级
- jquery事件委托
- 第11周OJ实践 循环画三角形
- 深入理解观察者模式(一)
- setTimeout()
- Objective-C是一门简洁、强大
- Java中 VO、 PO、DO、DTO、 BO、 QO、DAO、POJO的概念