<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>