2011-05-05 210 views
0

其实我想停止滚动的旗帜,当旗帜触摸div的底部请帮我........我使用此代码横幅滚动窗口滚动,但停止和不溢出div?

<script type="text/javascript"> 


    $(document).ready(function(){ 
    $(window).scroll(function(){ 
     if ($(window).scrollTop() > $(".smartBannerIdentifier").offset({ scroll: false }).top){ 
      $(".bannercomehere").css("position", "fixed"); 
      $(".bannercomehere").css("top", "0"); 
     } 

     if ($(window).scrollTop() <= $(".smartBannerIdentifier").offset({ scroll: false }).top){ 
      $(".bannercomehere").css("position", "relative"); 
      $(".bannercomehere").css("top", $(".smartBannerIdentifier").offset); 
     } 


     }); 


}); 
</script> 


<div> 
<div class="smartBannerIdentifier"></div>//here we stop the scroll of the banner and its on the top 
<div class="bannercomehere"> 

..................Here i call a Banner.............. 
</div> 
</div> 
</div> 
+0

请添加完整的代码代码与css – 2011-05-05 05:26:02

+0

没有任何css – user725013 2011-05-05 05:31:53

+0

你包括任何新的js或Jqery.Ui – 2011-05-05 05:39:03

回答

0
$(document).ready(function() 
     { 
      $(window).scroll(function() 
      { 
       if ($(window).scrollTop() > $(".smartBannerIdentifier").offset().top) 
       { 
        $(".bannercomehere").css("position", "fixed"); 
        $(".bannercomehere").css("top", "0"); 
       } 

       if ($(window).scrollTop() <= $(".smartBannerIdentifier").offset().top) 
       { 
        $(".bannercomehere").css("position", "relative"); 
        $(".bannercomehere").css("top", $(".smartBannerIdentifier").offset); 
       } 


      }); 


     });