-4
這是我的第一個問題。在主頁上滾動後,使標題改變顏色有問題。我搜索了Stackoverflow存檔,發現這個thread,但不知道如何使這個工作在my site。有人可以告訴我如何整合這個?由於如何在頁面滾動後改變標題顏色?
這是我的第一個問題。在主頁上滾動後,使標題改變顏色有問題。我搜索了Stackoverflow存檔,發現這個thread,但不知道如何使這個工作在my site。有人可以告訴我如何整合這個?由於如何在頁面滾動後改變標題顏色?
說起來很簡單,只要使用此javascript:
window.addEventListener("scroll","myFunction");
function myFunction() {
var myscroll = 200; // Replace this value with the height you want to scroll
// to change the header background
var myheader = ; // your header selector here
if (document.body.scrollTop > myscroll || document.documentElement.scrollTop > myscroll) {
myheader.style.backgroundColor = "#40A824"; // Replace this with the
// color you want after scrolling
}
}
如果您所提到的問題的答案是不夠清楚,我不知道怎麼會有人使它更清楚。 – George
歡迎來到Stack Overflow!尋求代碼幫助的問題必須包含在問題本身中重現**所需的最短代碼**最好在[** Stack Snippet **]中(https://blog.stackoverflow.com/2014/09/introducing-runnable) -javascript-CSS-和HTML的代碼段/)。請參閱[**如何創建一個最小,完整和可驗證的示例**](http://stackoverflow.com/help/mcve) –
您的回答沒有幫助我什麼.. – Dor