好吧,写这篇文章主要是为了刷一下存在感的,有是小半月没更新了,发生了很多事,让人无力吐槽;俗话说,好像不是俗话,人艰不拆......
为博客添加带微博按钮返回顶部效果,具体效果如下
html代码部分
<div id="share"> <a id="totop" title="">返回顶部</a> <a href="http://weibo.com/shenghao2011" target="_blank" class="sina">新浪微博</a> <a href="http://t.qq.com/shenghao_liu" target="_blank" class="tencent">腾讯微博</a> </div>
Js代码部分
//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; }); }); });
css代码部分
/*share_start*/ #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;} /*share_end*/
其他具体CSS细节请自行调节,当然页面引入jquery.js时必须的,搞定收工。
最后放一个演示地址:Demo
慢慢上升,效果不错~
微博是无孔不入啊,我还没养成刷微博的习惯,怎么破
我有小火箭
这个挺好的
纯支持了,有没有那种到底部,到评论的那种?
a id="pinglun" href="#respond"
看下你评论框那里id是什么;到底部的话就是href="#footer"
一个效果带来无限可能
哇咔咔,现在图标都win8风格了,还是可以。不错,期待更多好的分享。。。
带微博按钮 又更近一步了
学到,期待博主更多分享,持续关注
没看出来什么效果呀