以下是 我喜欢右侧微信返回顶部代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="JS代码,悬浮漂浮,JS广告代码,JS特效代码" />
<meta name="description" content="此代码内容为我喜欢右侧微信返回顶部,属于站长常用代码" />
<title>我喜欢右侧微信返回顶部</title><link type="text/css" href="css/lrtk.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/js.js"></script>
</head>
<body>
<!-- 代码开始 -->
<div id="code"></div>
<div id="code_img"></div>
<a id="gotop" href="javascript:void(0)"></a>
<!-- 代码结束 -->
<div id="tag_about" style="width:1000px; height:3000px; background:#F90; margin:0 auto;">
<div style="font:normal 12px/2em '微软雅黑';text-align:center;padding:50px 0;">
微信返回顶部,程序员设计师联盟淘宝店推荐下载!</p>
<p>使用方法:</p>
<p>1.引用样式文件css/lrtk.css</p>
<p>2.引用jquery的库文件js/jquery.js</p>
<p>3.引用效果的具体js代码文件js/js.js</p>
<p>4.html文件中,需要复制<!-- 代码开始 --><!-- 代码结束 -->中间代码</p>
<p>5.已考虑IE6的兼容问题,请放心使用</p></p>
<p></p>
</div>
</div>
</body>
</html>
JS代码(js.js):
function b(){
h = $(window).height();
t = $(document).scrollTop();
if(t > h){
$('#gotop').show();
}
else{
$('#gotop').hide();
}
}
$(document).ready(function(e){
b();
$('#gotop').click(function(){
$(document).scrollTop(0);
}
)$('#code').hover(function(){
$(this).attr('id','code_hover');
$('#code_img').show();
}
,function(){
$(this).attr('id','code');
$('#code_img').hide();
}
)}
);
$(window).scroll(function(e){
b();
}
)
CSS代码(lrtk.css):
/* ת���뱣���Ȩ��Ϣ������ͼ�� www.lanrentuku.com */
*{padding:0px;margin:0px;}
*html{background-image:url(about:blank);background-attachment:fixed;}
/*���IE6�¹�������������*/
/*���IE6�²����� position:fixed ������*/
#code,#code_hover,#gotop{width:36px;height:48px;background:url(../images/icon.png) no-repeat;position:fixed;right:50px;cursor:pointer;_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)));}
#code{background-position:-276px -258px;bottom:120px;_margin-bottom:120px;}
#code_hover{background-position:-316px -258px;bottom:120px;_margin-bottom:120px;}
#gotop{background-position:-276px -310px;bottom:67px;_margin-bottom:67px;}
#code_img{width:270px;height:355px;background:url(../images/icon.png) -4px -3px no-repeat;position:fixed;right:90px;bottom:67px;cursor:pointer;display:none;_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)));_margin-bottom:67px;}