看这篇文章之前,建议大家先看
jQuery---10行代码搞定跟随屏幕滚动的层.
http://www.cssrain.cn/article.asp?id=1177

这个7行代码的,意思也差不多,只不过少了3行代码,嘿嘿。
先看演示:
http://www.cssrain.cn/demo/floatDIV.html

具体代码:
先绝对定位 div 层,
然后脚本控制层的位置:
$(document).ready(function(){
    var menuYloc = $("#test").offset().top;
    $(window).scroll(function (){
        var offsetTop = menuYloc + $(window).scrollTop() +"px";
        $("#test").animate({top : offsetTop },{ duration:600 , queue:false });
    });
});

本篇文章来源于 cssrain.cn 原文链接:http://www.cssrain.cn/article.asp?id=1326

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
  • 2022-01-05
  • 2021-10-20
  • 2021-10-06
  • 2021-11-24
  • 2022-12-23
猜你喜欢
  • 2022-02-19
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案