1、此博文圖片樣式引用騰訊網站,效果如下:
2、樣式設置:
#toTop { /*選中的背景圖片的大小*/ width: 54px; height: 54px; display: none;/*剛開始不顯示*/ position: fixed; right: 25px;/*距離右邊大小值*/ bottom: 45px;/*距離底部大小值*/ /*選定圖片區域*/ background-image: url(images/qqbg_1.5.5.png); background-repeat: no-repeat; background-position: -700px -110px; opacity: 0.3; /*透明度*/ } #toTop:hover { opacity: 1;/*懸停時不透明*/ filter: alpha(opacity = 100); }
3、JS代碼:
<a href="#" target="_self" id="toTop" title="返回頂部" onclick="window.scrollTo(0,0);return false"></a> <script type = "text/javascript"> function toTopHide(){ $(document).scrollTop()>400? $("#toTop").show() :$("#toTop").hide(); } $(window).scroll(function(){toTopHide()}); </script>
推薦一個自己業余時間開發的網盤搜索引擎,360盤搜(www.360panso.com)