本浮动层基于jQuery1.6.2,对于研究1.6版本的jquery很有帮助意义。
<!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><link rel="dns-prefetch" href="//www.jiangweishan.com"><link rel="dns-prefetch" href="//www.jiangweishan.comsearch.php"><link rel="dns-prefetch" href="//shang.qq.com"><link rel="dns-prefetch" href="//www.w3.org"><link rel="dns-prefetch" href="//www.jb51.net"><link rel="dns-prefetch" href="//files.jb51.net"><link rel="dns-prefetch" href="//www.mockplus.cn"><link rel="dns-prefetch" href="//www.aliyun.com"><link rel="dns-prefetch" href="//pagead2.googlesyndication.com"><link rel="dns-prefetch" href="//weibo.com"><link rel="dns-prefetch" href="//beian.miit.gov.cn"><link rel="dns-prefetch" href="//hm.baidu.com"><link rel="dns-prefetch" href="//www.zblogcn.com"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>jquery浮动层</title><style type="text/css"> #Float {background-color: #000;height: 200px;width: 100px;position: absolute;top: 80px;right: 20px;} </style></head><script type="text/javascript" src="http://www.jb51.net/jslib/jquery/jquery-1.6.2.min.js"></script><script language="javascript"> $(document).ready(function(){ $(window).scroll(function (){ var offsetTop = $(window).scrollTop() + 80 +"px"; $("#Float").animate({top : offsetTop },{ duration:500 , queue:false }); }); }); </script><body><div style="height:2000px;"></div><div id="Float"></div></body></html>
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
基于jquery的浮动层效果代码
未经允许不得转载:工具盒子 » 基于jquery的浮动层效果代码