百度空间 | 百度首页 
 
查看文章
 
Jquery - - 跟随屏幕滚动的层
2008年11月18日 星期二 15:37
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>跟随屏幕滚动的层</title>
<style>
* { margin:0; padding:0; }
#yj { background:#BBB; border:2px double #000000; position:fixed; left:0px; top:0px; height:200px; width:200px; }
</style>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
         /*FF和IE7可以通过position:fixed来定位,只有ie6需要动态设置高度.*/
    if($.browser.msie && $.browser.version == 6) {
     FollowDiv.follow();
    }
});
FollowDiv = {
    follow : function(){
     $('#cssrain').css('position','absolute');
     $(window).scroll(function(){
        var f_top = $(window).scrollTop();
      $('#cssrain').css( 'top' , f_top );
     });
    }
   }
</script>
</head>
<body>
<div style="width:100%;height:600px;">test</div>
<div id="yj"> 跟随屏幕滚动的层 </div>
<div style="width:100%;height:600px;">test</div>
</body>
</html>

类别:jquery专区 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu