大家用wordpress来 做站都是会碰到网页页面內容较为长的情况下,左右拖拖拉拉网页页面确实不便,此刻就要一个wordpress回到顶部的作用了。在网上有关实例教程也一大堆,也是js脚本制作 啊,也是JQuery啊什么样的,太麻烦了,而今日共享的是沒有js读取的,立即加个款式,再在底端加个编码就结束了,下边将此教程分享给大伙儿!
1. 在style.css中加上如下所示编码:
- #gotop{ width:38px; height:36px; position:fixed; bottom:25px; right:10px; top:auto; display:block; cursor:pointer; background: url(images/gotop.gif) no-repeat}*html #gotop{ position:absolute; bottom:auto; top:expression(eval(document.documentElement.scrollTop document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));}
在其中,bottom和right特性可以操纵按钮图片在右下方的部位,background特性可以改动回到顶部的照片。
2. 在footer.php中加上如下所示编码:
- <!– 回到顶部 –><div style=“display: none;” id=“gotop”></div><script type=’text/javascript’> backTop=function (btnId){ var btn=document.getElementById(btnId); var d=document.documentElement; var b=document.body; window.onscroll=set; btn.onclick=function (){ btn.style.display=“none”; window.onscroll=null; this.timer=setInterval(function(){ d.scrollTop-=Math.ceil((d.scrollTop b.scrollTop)*0.1); b.scrollTop-=Math.ceil((d.scrollTop b.scrollTop)*0.1); if((d.scrollTop b.scrollTop)==0) clearInterval(btn.timer,window.onscroll=set); },10); }; function set(){btn.style.display=(d.scrollTop b.scrollTop>100)?’block’:“none”} }; backTop(‘gotop’);</script><!– 返回顶部END –>
3. 加上回到顶部按钮图片 可以选择自己喜爱的
将照片储存到主题风格文件夹名称下的images里,照片名字叫做gotop.gif
实例教程转自:http://www.2zzt.com/jcandcj/3292.html