一般我们遇到比较长页面的网站,会在右侧方加上访问顶部的小浮动按钮,我们可以点击后直接回到网页的首屏中,于是这类问题经常出现的时候老蒋会收藏整理一个通用的代码脚本,在需要用到的时候直接贴进来使用。这里把我整理过来的方法一并记录到网站中,有需要的朋友可以选择。同时也方便我以后的再次复制。
第一、通用CSS文件
#gotop{
width:38px;
height:36px;
position:fixed;
bottom:25px;
right:10px;
top:auto;
display:block;
cursor:pointer;
background: url(images/topav.jpg) 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)));
}
Select CodeCopy
通用css文件,我们可以修改一下对应的图片"images/topav.jpg",我们准备准备一个箭头上的图片。
第二、添加页面脚本
发表评论 取消回复