├── img ├── to-top.png └── to-top-hover.png ├── README.md ├── back2top.css └── back2top.js /img/to-top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxlie/back2top/HEAD/img/to-top.png -------------------------------------------------------------------------------- /img/to-top-hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zxlie/back2top/HEAD/img/to-top-hover.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 网页返回顶部组件(back2top) 2 | ========================== 3 | 4 | ### 简介 5 | 基于jQuery的返回顶部控件,使用方法简单,只需要Back2top.init()即可;如果用户需要自定义样式,可以直接更改back2top.css文件 6 | 7 | ### 详细api文档 8 | http://www.baidufe.com/component/back2top/index.html -------------------------------------------------------------------------------- /back2top.css: -------------------------------------------------------------------------------- 1 | /*回到顶部按钮*/ 2 | #doitbegin_Back2top { 3 | display:block; 4 | width:38px; 5 | height:38px; 6 | background:url(./img/to-top.png) no-repeat; 7 | position: fixed; 8 | _position:absolute; 9 | right:20px; 10 | bottom: 20px; 11 | z-index: 10; 12 | cursor: pointer; 13 | text-indent: -999em; 14 | } 15 | #doitbegin_Back2top:hover { 16 | background:url(./img/to-top-hover.png) no-repeat; 17 | } -------------------------------------------------------------------------------- /back2top.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 返回顶部 3 | * 4 | * @homepage http://www.baidufe.com/component/back2top/index.html 5 | * @author zhaoxianlie 6 | */ 7 | var Back2top = (function($,undefined){ 8 | 9 | /** 10 | * 动画时间,默认为:300ms 11 | * @type {Number} 12 | * @private 13 | */ 14 | var _timeInterval = 300; 15 | 16 | /** 17 | * 浏览器信息 18 | * @type {*} 19 | */ 20 | var browserInfo = (function(){ 21 | var userAgent = navigator.userAgent.toLowerCase(); 22 | return { 23 | version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1], 24 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ) 25 | }; 26 | })(); 27 | 28 | /** 29 | * 节点安装 30 | */ 31 | var setup = function(){ 32 | /** 33 | * 创建返回顶部的节点 34 | * @type {*|jQuery} 35 | */ 36 | var elBack2Top = $('