請(qǐng)問怎么實(shí)現(xiàn)滾動(dòng)監(jiān)聽???寫了js代碼,沒反應(yīng),想滾動(dòng)200px,導(dǎo)航條背景改變
?? ?<nav class="navbar navbar-default navbar-fixed-top navbar-inverse"role="navigation"id="title">
<script type="text/javascript">
? ? window.onscroll = function(){
? ? var t = document.documentElement.scrollTop || document.body.scrollTop;
? ? var title = document.getElementById("title");
? ? if( t >=300 ) {
? ? ? title.style.background-color=rgba(0,0,0,1);
? ? }?
? ? else {
? ? ? title.style.background-color=rgba(0,0,0,0);
? ? }
? }
2017-08-08
對(duì)照著看一下,jq很方便的,但是不建議這樣去改,最好去自定義你的bootstrap框架。簡單的多