2014-03-13 29 views
0

我遇到了一個我試圖實施的粘性導航/橫幅圖像二重奏的問題。 看看這裏:http://lucid-build.com/stack/sticky/ 問題是,當我調整窗口的大小,橫幅的位置是關閉的。否則,它就像它應該的那樣行事。 關於如何解決這個問題的任何建議將不勝感激!關閉窗口中的橫幅位置用粘滯導航調整大小

[編輯]這是劇本!

function resizeBanner() { 
    var bannerH = $(".banner img").height(); 
    $(".banner").css("height", bannerH); 
} 

function fixedNav() { 
    var logoT = $(".logo").offset().top; 
    var bannerH = $(".banner img").height(); 

    $(window).scroll(function() { 
     if($(window).scrollTop() > logoT) { 
      $("#header").addClass("fixed").css(("height"),120); 
      $(".banner").css(("margin-top"),-bannerH+120); 
      $("body").css(("margin-top"),bannerH+18);  
     } else { 
      $("#header").removeClass("fixed").css(("height"),("auto")); 
      $(".banner").css(("margin-top"),0); 
      $("body").css(("margin-top"),0); 
     } 
    }); 
} 


$(window).resize(function() { 
    resizeBanner(); 
}); 

$(window).load(function() { 
    resizeBanner(); 
    fixedNav(); 
}); 

$(document).ready(function() { 
    resizeBanner(); 
}); 
+0

我們簽出的任何代碼?這個粘性導航/橫幅實際上是如何粘性的? –

+0

剛剛添加腳本到我原來的帖子! :) – angelwhite

回答

0

你只需要添加到具有類「旗幟」的元素的CSS:

position : absolute; 
bottom : 0; 

PS:其實你的箱子是在調整的權利,但它在頂部由默認的左置您設置的標題。由於父框設置在position:relative上,所有絕對元素都將引用該父級而不是整個文檔。

+0

哦,我的天哪,多麼簡單的修復!我現在覺得有點傻了哈哈。非常感謝! – angelwhite