如果有一定的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>top: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 inix() <BR>{ <BR>advInitTop=document.getElementById("ad").style.pixelTop; <BR>closeInitTop=document.getElementById("cl").style.pixelTop; <BR>} <BR>function closeAd() <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.getElementById("cl").style.pixelTop=document.documentElement.scrollTop+closeInitTop; <BR>//alert(document.getElementById("ad").style.pixelTop); <BR>window.status=document.documentElement.scrollTop+"/"+document.getElementById("ad").style.pixelTop; <BR>} <BR>window.onscroll=move; <BR> 要点: 上述代码中要用document.documentElement ,不要用老的document.body,否则,不符合w3c标准,看不到浮动效果!