在以下代碼中,標題顏色是透明的。當我向下滾動頁面時,我想將其顏色更改爲「#FFF」。請指導我如何爲它編寫相關的js代碼。如何將標題的背景顏色從透明更改爲白色?
此外,它可以通過普通的CSS來完成?
div {
height: 1000px;
width: 100%;
}
#home {
background-color: red;
}
header {
background-color: transparent;
color: ffffff;
height: 100px;
position: fixed;
width: 100%;
top: 0;
z-index: 100;
}
<header>Top Navigation</header>
<div id="home" class="sect"></div>
的可能重複:http://stackoverflow.com/questions/11434735/change-element-style-on-page-scroll – Aziz