2013-01-10 230 views
2

此功能的jQuery,滾動股利(名爲「搜索」的CSS),當用戶滾動頁面..滾動一個div時滾動頁面

$(window).scroll(function(){ 
    $.each($('.Search'),function(){ 
     var windowpos = $(window).scrollTop(); 
     var finaldestination = windowpos+90; 
     $(this).stop().animate({'top':finaldestination},300); 
    }); 
}); 

此功能的jQuery不上網工作Explorer 9. 我試圖做一個包含屬性位置的CSS:固定但在Internet Explorer 9中不起作用。 有一種解決方案,允許我在用戶在Internet Explorer中滾動頁面時滾動div。 對於基礎英語我很抱歉

+2

「位置:固定」在IE9中不起作用的唯一原因是,頁面以怪癖模式呈現時,只有當您的HTML無效時 –

回答

0

在IE中可以正常工作。我用搜索的CSS是

.search { 
    position: absolute; 
    top: 90px; 
} 

Working Demo

編輯

要獲得更快的動畫過渡,清除隊列。

.stop(true) 
2

只能使用CSS ...

.search { 
    width: 200px; 
    height: 50px; 
    background-color: red; 
    position: fixed; 
    top: 90px; 
} 

Example

問候。