一个带微博按钮的jquery返回顶部效果代码

原文地址:http://lanyes.org/web/552.html

JQUERY代码部分,复制代码到</head>之前即可。
<script src="http://libs.baidu.com/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
//scrolltotop
$(function(){
        //首先将#back-to-top隐藏
        $("#totop").hide();
        //当滚动条的位置处于距顶部100像素以下时,跳转链接出现,否则消失
        $(function () {
            $(window).scroll(function(){
                if ($(window).scrollTop()>100){
                    $("#totop").fadeIn();
                }
                else
                {
                    $("#totop").fadeOut();
                }
            });
            //当点击跳转链接后,回到页面顶部位置
            $("#totop").click(function(){
                $('body,html').animate({scrollTop:0},500);
                return false;
            });
        });
    }); 
</script>

css部分:

CSS部分,复制到你网站的CSS样式里面。#share {position:fixed;_position:absolute;_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight)-34+"px");bottom:34px;left:95%;width:30px;zoom:1;}#share a{background-image:url(images/share.png); background-repeat:no-repeat; display:block; width:30px; height:30px; margin-bottom:2px; overflow:hidden; text-indent:-999px;-webkit-transition: all 0.2s ease-in-out;-moz-transition: all 0.2s ease-in-out;-o-transition: all 0.2s ease-in-out;-ms-transition: all 0.2s ease-in-out;transition: all 0.2s ease-in-out;}#share a{}#share .sina {background-position:0 0; position:absolute; bottom:32px;}#share a.sina:hover { background-position:-30px 0;}#share .tencent { background-position:0 -30px; position:absolute; bottom:0;}#share a.tencent:hover { background-position:-30px -30px;}#share a#totop{background-position:0 -120px;position:absolute;bottom:64px;cursor:pointer;}#share a#totop:hover {background-position:-30px -120px;}

html部分:

html代码部分,修改后复制到</body>代码前。<div id="share"><a id="totop" title="">返回顶部</a><a href="http://t.qq.com/lanyesorg" target="_blank" class="sina">关注蓝叶新浪微博</a><a href="http://t.qq.com/lanyesorg"  target="_blank" class="tencent">关注蓝叶腾讯微博</a></div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值