2015-04-26 39 views
0

演示前面元素的高度跳躍。爲此,我正在使用:https://github.com/Victa/scrolly的jQuery插件Scrolly視差背景由

雖然問題。當在視差橫幅之前放置一個元素時,當您開始滾動時,視差背景的位置將跳過前一個元素的高度。

在這種情況下,紅色橫幅是218px高。當你開始滾動時,綠色背景的位置將跳躍218px。

注意:如果視差元素是頁面上的第一個元素,這不是問題。如果紅色橫幅通過固定位置從文檔流中移除,這也不是問題。

我想的罪魁禍首,它可能這一點,但不知道從哪裏開始診斷:

// Fix background position 
if(this.bgStart){ position = position + this.bgStart; } 

if(this.options.bgParallax === true) { 
    this.$element.css({backgroundPosition: '50% '+position+'px'}); 
} else { 
    this.$element.css({top: position}); 
} 

非常感謝所有的指針。謝謝! :)

+0

可以顯示更多的代碼,請 –

+0

嗨的。完整的Js可以在這裏找到:http://christianbullock.org/jstest/jquery.scrolly.js。謝謝 :) – Christian

回答

1

固定。不得不補充:

data-fit="-218" 

在頂部佔旗幟:)