Jquery插件-返回顶部
原创
©著作权归作者所有:来自51CTO博客作者abao0918的原创作品,请联系作者获取转载授权,否则将追究法律责任
1.引入jQuery类库及插件库,效果及插件请看附件
<script type="text/javascript" src="js/jQuery-1.4.2.js"></script>
<script type="text/javascript" src="js/jquery.scrolltotop.js"></script>
2.样式控制
<style type="text/css">
/* 返回top样式*/
.totop {
width: 40px;
height: 35px;
line-height: 35px;
font-size: 12px;
overflow: hidden;
}
.totop a {
display: block;
width: 40px;
height: 35px;
background: url(p_w_picpaths/totop.gif) no-repeat;
text-indent: -9999px;
text-decoration: none;
}
.totop a:hover {
background-position: 0 -35px;
}
</style>
3.body内容
<div style="margin-top:200px;text-align:center;height:1000px;background-color:#cccccc;">
这是body内容,滚动滚动条,请看右下角。
</div>
4.JS控制出现返回顶部图片
<script type="text/javascript">
$(function($){
// 返回顶部
$.scrolltotop({
className: 'totop',
// controlHTML : '<a href="javascript:;">回到顶部↑</a>',
// 此处可以换成下面的图片格式
// controlHTML : '<img title="返回顶部" src="p_w_picpaths/totop.gif"/>'
offsetx : 25,// 回到顶部 right 偏移位置
offsety : 25,// 回到顶部 bottom 偏移位置
});
});
</script>
更多资讯请移步路人甲技术交流http://www.walkerjava.com
上一篇:新闻或消息上下滚动
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
返回顶部的插件
插件 manhuatoTop.js 样式 manhuatoTop.css 使用方法
css javascript 返回顶部 -
【jquery】返回顶部效果jquery版
以前写过返回顶部效果(javascript版),具体内容点击这里。后来应用在了博客上,由于博客园原本就是用的 jquery,所以就写了
javascript ViewUI jquery 返回顶部 -
jQuery返回顶部代码组件
html返回顶部插件
html top jquery github 自定义
















