现在各大网站都能看到有返回顶部的快捷处理,下面就简单看看用css和jquery如何实现吧:
<html style="height:1000px">
<head>
<style type="text/css">
#totop a {
display: block;
width: 50px;
height: 50px;
overflow: hidden;
background-color: red;
}
#totop {
position: fixed;
bottom: 50px;
right: 15px;
cursor: pointer;
z-index: 999999;
display: block;
opacity: 1;
}
div ul{
height:60px;
width: 120px;
border:1px solid blue;
}
div ul li{
height:60px;
width: 40px;
list-style: none;
float:left;
}
</style>
</head>
<body>
<div>
<ul>
<li>111</li>
<li>222</li>
<li>333</li>
</ul>
</div>
<p>this is some text.this is some text.this is some text.this is some text.</p>
<div id="totop">
<a title="返回顶部">返回顶部</a>
</div>
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript">
$(function(){
var upperLimit=80;
var scrollElem=$("#totop");
var scrollSpeed=500;
scrollElem.hide();
$(window).scroll(function(){
var scrollTop=$(document).scrollTop();
if (scrollTop>upperLimit){
scrollElem.stop().fadeTo(300,1);
}else{
scrollElem.stop().fadeTo(300,0);
}
});
scrollElem.click(function(){
$('html,body').animate({scrollTop:0},scrollSpeed);
return false;
});
});
</script>
</body>
</html>
分享到:
相关推荐
Python代码源码-实操案例-框架案例-空值处理方案….zip
Python代码源码-实操案例-框架案例-如何处理数据表的长宽转换.zip
jsp案例---端午节jsp案例---端午节jsp案例---端午节jsp案例---端午节jsp案例---端午节jsp案例---端午节
Vue入门学习小案例-小王记事本 Vue入门学习小案例-小王记事本 Vue入门学习小案例-小王记事本 Vue入门学习小案例-小王记事本 Vue入门学习小案例-小王记事本 Vue入门学习小案例-小王记事本 Vue入门学习小案例-小王...
Python代码源码-实操案例-框架案例-处理时间频率问题.zip
Python代码源码-实操案例-框架案例-重复数据处理(df.drop duplicates方法).zip
VC++2005管理系统开发经典案例--源码--图书管理系统 内含源代码及SQL数据库脚本
精通Java EE项目案例-基于Eclipse Spring Struts Hibernate光盘源码(第二版) PART3
锐捷交换机配置案例-S3760-24配置案例锐捷交换机配置案例-S3760-24配置案例锐捷交换机配置案例-S3760-24配置案例锐捷交换机配置案例-S3760-24配置案例
精通Java EE项目案例-基于Eclipse Spring Struts Hibernate光盘源码分享给大家的实战案例很值得参考,带数据库版!!!!
基于vue编写的一些自定义bpmn.js案例-基础篇.zip基于vue编写的一些自定义bpmn.js案例-基础篇.zip基于vue编写的一些自定义bpmn.js案例-基础篇.zip基于vue编写的一些自定义bpmn.js案例-基础篇.zip基于vue编写的一些...
强烈推荐Python语言教程及案例--《Python语言及其应用》.pdf强烈推荐Python语言教程及案例--《Python语言及其应用》.pdf强烈推荐Python语言教程及案例--《Python语言及其应用》.pdf强烈推荐Python语言教程及案例--...
精通Java EE项目案例-基于Eclipse Spring Struts Hibernate光盘源码.rar精通Java EE项目案例-基于Eclipse Spring Struts Hibernate光盘源码.rar精通Java EE项目案例-基于Eclipse Spring Struts Hibernate光盘源码....
so加固案例--加密section so加固案例--加密section
煤气爆炸事故案例-事故案例-案例分析-爆炸事故.docx
Python代码源码-实操案例-框架案例-按照京东运营要求将图片批量处理为指定大小.zip
导热油炉爆炸事故案例-事故案例-案例分析-锅炉事故.docx
大牛出手Oracle 11.2.0.3 RAC 与 RAC 之间搭建Data Guard 案例 -- Aative Data Guard 案例
Python代码源码-实操案例-框架案例-解决直接访问请求地址返回403错误的问题,.zip
大数据综合案例-网站日志分析,主要是文档,使用大数据离线分析日志。