浮动层 div 固定位置

 1 holdPostion : function(){
 2             var $cont  = $(".cont"),
 3                 $guide = $(".guide"),
 4                 offset = $guide.offset(),    // jQuery 的 offset() 是相对于 document文档的 偏移 --  、js 的 offsetLeft 是相对于定位的 Parent 偏移 
 5                 t      = offset.top,
 6                 l      = offset.left,
 7                 str;
 8 
 9             // 非 IE 6
10             if(!Widget.isIE6){
11                 $(global).scroll(function(){
12                     str = {'position' : 'fixed', 'top' : '351px', 'left' : l}
13                     $guide.css(str);
14                 });
15                 $(global).resize(function(){
16                     l = 980 + $cont[0].offsetLeft +'px';
17                     str = {'position' : 'fixed', 'top' : '351px', 'left' : l}
18                     $guide.css(str);
19                 });
20                 return;
21             }
22 
23             // IE 6
24             $(global).scroll(function(){
25                 t = $(this).scrollTop() + 'px';
26                 str = {'position' : 'absolute', 'top' : t, 'right' : '-140px'}
27                 $guide.css(str);
28             });
29 
30         }

var Widget = {

     isIE : !!document.all,                   // 判断是不是IE浏览器
  isIE6 : !window.XMLHttpRequest  // 判断是不是ie6
};

原文地址:https://www.cnblogs.com/chuyu/p/3370076.html