您的位置:首页 > Web前端 > JQuery

jQuery实现跟随页面滚动的浮动层效果

2014-10-21 10:52 681 查看
<!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=utf-8" />
<title>jQuery实现跟随页面滚动的浮动层效果</title>
<script type="text/javascript" src="/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
if ($.browser.version != "6.0") {
$(window).scroll(function(){
if($(this).scrollTop()>118  &&(($(document).height()-$(this).scrollTop())>($(window).height()+$(".aysw-footer").innerHeight()))){
$("#c_left").css({position: 'fixed', top: '2px'});
}else{
if(($(document).height()-$(this).scrollTop())<=($(window).height()+$(".aysw-footer").innerHeight())){
$("#c_left").css({position: 'absolute', top:($(".aysw-footer").offset().top-$("#c_left").innerHeight()-$(".page-home").offset().top-20) +'px'});
}else{
$("#c_left").css({position: 'absolute', top: '2px'});
}
}
});
}
</script>
</head>
<body style="height:auto; margin:0; padding:0">
<div style="height:118px;background:#6CF;"><br>所需js文件:<a href="/js/jquery-1.6.2.min.js" target="_blank">jquery-1.6.2.min.js</a><br><hr><p align="center"><font color=black>本特效由 <a href="http://www.hbycshop.com" target="_blank">亿诚</a>丨www.hbycshop.com 收集于互联网,只为兴趣与学习交流,不作商业用途。</font></p></div>
<div class="page-home" style="min-height:1500px;width:100%; background-color:#FFC; position:relative">
<div id="c_left" style="border:1px solid red; width:200px ;height:800px; color:white;background-color:#333; position:absolute; top:2px">
羞涩的浮动层...
</div>
</div>
<div class="aysw-footer" style="height:200px; width:100%; background-color:#0C3; position:relative"></div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: