兩側廣告漸變出現漸變隱藏


<script type="text/javascript">
$(function(){

//定位div距離瀏覽器頂部的距離


var navH = 820;


//滾動條事件

$(window).scroll(function(){

//獲取滾動條的滑動距離

var scroH = $(this).scrollTop();

//滾動條的滑動距離大於等於定位元素距離瀏覽器頂部的距離,就漸變出現,反之就漸變隱藏

if(scroH>=navH){

$(".nav").fadeIn( 1000 );//1000是時間1秒

}else if(scroH<navH){

$(".nav").fadeOut( 1000 );

}

}
)

}) 

</script>

<!--下面是實驗的div代碼-->

<div style="background-color:#063;  height:820px"></div>
  <div class="nav" style=" position: fixed ! important; display:none; left: 50px; top:150px; background-color:#900; width:100px; height:100px;"></div>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章