如果有一定的JavaScript基礎,製作浮動廣告還是比較容易的。直接上代碼了: 複製代碼 代碼如下: 無標題文件 <BR>*{ <BR>margin:0; <BR>padding:0; <BR>} <BR>#csdn <BR>{ <BR>width:800px; <BR>margin:0 auto; <BR>} <BR>#ad <BR>{ <BR>position:absolute; <BR>right:0px;{ <BR>position:absolute; <BR>right:0ppx; 30px; <BR>z-index:1; <BR>} <BR>#cl <BR>{ <BR>position:absolute; <BR>right:0px; <BR>top:30px; <BR>z- index:2; <BR>} <BR> <BR>var advInitTop=30; <BR>var closeInitTop=30; <BR>function in🎜>var closeInitTop=30; <BR>function in🎜>var closeInitTop=30; <BR>function in🎜>var closeInitTop=30; <BR>function in🎜>var closeInitTop=30; <BR>function in🎜>var closeInitTop=30; <BR>function 在) <BR>{ <BR>advInitTop=document.getElementById("ad").style.pixelTop; <BR>closeInitTop=document.getElementById("cl").style.pixelTop; <BR>> () <BR>{ <BR>document.getElementById("ad").style.display="none"; <BR>document.getElementById("cl").style.display="none"; <BR>} <BR>function move() <BR>{ <BR>//document.getElementById("ad").style.pixelTop=document.body.scrollTop advInitTop; <BR>//document.getElementById("cl"). style.pixelTop=document.body.scrollTop closeInitTop; <BR>document.getElementById("ad").style.pixelTop=document.documentElement.scrollTop advInitTop; <BR>document.documentElement.scrollTop advInitTop; <BR>document. document.documentElement.scrollTop closeInitTop; <BR>//alert(document.getElementById("ad").style.pixelTop); <BR>window.status=document.documentElement.scrollTop "/" document. ).style.pixelTop; <BR>} <BR>window.onscroll=move; <BR> 要點: 上述程式碼中要用document.documentElement ,不要用老的document.body,否則,不符合w3c標準,看不到浮動效果!