首页 »Javascript教程 » cssc.js:js CSS操作思路方法集合 »正文cssc.js:js CSS操作思路方法集合来源: 发布时间:星期四, 2008年12月25日 浏览:12次 评论:0
//获取元素
![]() ![]() ![]() ![]() ![]() ![]() function getStyle(elem,name){ ![]() ![]() } ![]() ![]() ![]() } ![]() ![]() name = name.replace(/([A-Z])/g,"-$1"); name = name.toLowerCase ![]() var s = document.defaultView.getComputedStyle(elem,""); ![]() } ![]() ![]() } } //两个确定元素相对于整个文档 ![]() ![]() function pageX(elem){ ![]() ![]() elem.off ![]() ![]() elem.off ![]() } function pageY(elem){ ![]() ![]() elem.off ![]() ![]() elem.off ![]() } //确定元素相对于父亲 ![]() ![]() ![]() function parentX(elem){ ![]() ![]() ![]() elem.off ![]() pageX(elem)-pageX(elem.parentNode); } function parentY(elem){ ![]() ![]() ![]() elem.off ![]() pageY(elem)-pageY(elem.parentNode); } //确定元素相对于它 ![]() ![]() function posX(elem){ ![]() } function posY(elem){ ![]() } //设置元素x和y位置(和当前位置无关) ![]() ![]() function ![]() elem.style.left = pos+"px"; } function ![]() elem.style.top = pos+"px"; } //调整元素相对于当前位置 ![]() ![]() ![]() function addX(elem,pos){ ![]() } function addY(elem,pos){ ![]() } //获取元素当前 ![]() function getHeight(elem){ ![]() } function getWidth(elem){ ![]() } //即是元素隐藏 ![]() ![]() ![]() ![]() function fullHeight(elem){ ![]() ![]() ![]() } var old = re ![]() display:'', visibility:'hidden', position:'absolute' }); var h = elem.clientHeight||getHeight(elem); restoreCSS(elem,old); ![]() } function fullWidth(elem){ ![]() ![]() ![]() } var old = re ![]() display:'', visibility:'hidden', position:'absolute' }); var w = elem.clientWidth || getWidth(elem); restoreCSS(elem,old); ![]() } function re ![]() var old = ![]() for(var i in prop){ old[i] = elem.style[i]; elem.style[i] = prop[i]; } ![]() } function restoreCSS(elem,prop){ for(var i in prop){ elem.style[i] = prop[i]; } } //使用CSS ![]() ![]() ![]() ![]() function hide(elem){ var curDisplay = getStyle(elem,'display'); ![]() elem.$oldDisplay= curDisplay; } elem.style.display = 'none'; } function show(elem){ elem.style.display = elem.$oldDisplay ||''; } //设置元素 ![]() function ![]() ![]() elem.style.filters = 'alpha(opacity='+level+')'; } ![]() elem.style.opacity = level/100; } } 0
相关文章读者评论发表评论 |
|