2013-07-13 26 views

回答

0

這是jQuery和一點點勤奮與$ .scroll和$ .animate和肯定$。點擊

3

無。它僅使用了一個精心製作的jQuery animate功能

$("html, body").animate({ 
    scrollTop:the_top 
},1000,function(){ 

這個網頁是一個單頁網站的一個完美的例子。所有的代碼都在頁面上內聯。

the_top被設置爲div,應在考慮到在click()65 PX的用於在網頁的頂部的菜單欄中空間的預定義offset().top()

酷菜單代碼

$("#menu a").click(function(e){ 
    e.preventDefault(); 

    var the_id = $(this).attr('href'); 
    var the_top = $("#div_"+the_id).offset().top - 65; 
    highlight_menu(the_id); 

    //$("#menu").animate({"top":"-=96"},500).animate({"top":"+=96"},500) 

    $("html, body").animate({ 
     scrollTop:the_top 
    },1000,function(){ 

    }) 
}) 

function highlight_menu(which) 
{ 
    $("#menu a").removeClass('this'); 
    $("#menu a[href='"+which+"']").addClass('this'); 
    $("#ball").animate({ 
     "left":$("#menu a[href='"+which+"']").position().left+$("#menu a[href='"+which+"']").width()/2+17+"px" 
    }, 750, function(){ 

    }) 
} 
+0

是的。打敗了我。 jquery使它很容易看起來不錯! – 2013-07-13 18:21:56

+0

哈哈沒問題,寫一個更好的解釋,我會投它:-) –

+0

lulz。呃,你釘了它。如果你不介意的話,我將編輯添加lil somthin ... – 2013-07-13 18:24:39

相關問題