問題描述
我正在使用 Bootstrap 3,并希望在用戶滾動經(jīng)過我的大標(biāo)題圖像時實現(xiàn) 這種效果頁.我需要導(dǎo)航欄的背景從透明變?yōu)榘咨?我查看了他們的代碼,我知道它是用 javascript 完成的,甚至看到了 WHERE 我認(rèn)為它發(fā)生了(在那個 JS 中查找 ID '#main-header')...
I'm using Bootstrap 3 and want to achieve this effect when the user scrolls past the large header image on my page. I need the background of the navbar to go from transparent to white. I looked in their code and I KNOW it is done with javascript, and even saw WHERE it was happening I think (look for the ID '#main-header' in that JS)...
除了不了解高級 Javascript 之外,我正在尋找一種在滾動超過某個點時將其應(yīng)用于導(dǎo)航欄的方法.我的代碼的類稱為導(dǎo)航欄",我希望它在通過#main"時變成白色.如果您需要更多信息,請告訴我,如果有人想提供幫助,請?zhí)崆爸轮x!
Not knowing advanced Javascript aside, I'm looking for a way to apply this to my navigation bar when scrolling past a certain point. The class for my code is called 'navbar' and I would like it to turn white when it passes "#main". Let me know if you need more information, and thanks in advance if anyone wants to help!
推薦答案
如果你使用 Twitter Bootstrap,這可以通過'Affix' 插件
If you're using Twitter Bootstrap this can be achieved with the 'Affix' plugin
設(shè)置起來非常簡單,這里是文檔
這篇關(guān)于滾動經(jīng)過錨點時,如何使導(dǎo)航欄更改 CSS 類?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!