代码片段特效基于javascript,务必将代码放到html后面,适合二次开发,拖动层必须在标签内写上style样式,并且有top和left属性。

var _customer = document.getElementById('customer');
_customer.style.display = 'block';
function position(){
_customer.style.top = '250px';
} lastScrollY=0;
function heartBeat(){
var diffY;
if (document.documentElement && document.documentElement.scrollTop)
diffY = document.documentElement.scrollTop;
else if (document.body)
diffY = document.body.scrollTop
else
{/*Netscape stuff*/} //alert(diffY);
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
_customer.style.top=parseInt(_customer.style.top)+percent+"px"; lastScrollY=lastScrollY+percent;
//alert(lastScrollY);
}
window.setInterval("heartBeat()",50);
演示,用于漂浮的客服窗口效果。-开源中文css框架