高人帮我看下这个JS什么意思

来源:百度知道 编辑:UC知道 时间:2024/06/24 12:52:40
function closepiao(){
document.getElementById("piao").style.display="none";
}
document.getElementById("piao").style.left=((document.documentElement.clientWidth-100)-document.getElementById("piao").offsetWidth/2)+"px";
document.documentElement.onscroll=function(){
el=document.getElementById("piao");
el.style.top=(document.documentElement.scrollTop+100)+"px";
el.style.left=((document.documentElement.clientWidth-100)-el.offsetWidth/2)+"px";
}

这个大概帮我翻译一下,

//这是通过js操作CSS属性,达到操作元素的效果
function closepiao(){
//document.getElementById("piao")获取id="piao"的html元素
//后面的是设置这个元素的样式为隐藏
document.getElementById("piao").style.display="none";
}
document.getElementById("piao").style.left=((document.documentElement.clientWidth-100)-document.getElementById("piao").offsetWidth/2)+"px";
//执行滚动事件触发
document.documentElement.onscroll=function(){
el=document.getElementById("piao");
//设置元素位置(元素的左上角)
el.style.top=(document.documentElement.scrollTop+100)+"px";
el.style.left=((document.documentElement.clientWidth-100)-el.offsetWidth/2)+"px";
}