2011-05-05 291 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); 
       } 


      }); 


     });