Web开发网 > 站内搜索 > offsetparent
static),不管diplay是否为none,IE8标准下,元素A的offsetParent 取值是body元素,IE7标准和Quirks下返回的是元素A的根元素; 2、当元素A的祖先元素级别中某祖先元素的position不是默认值(static),diplay不为none,IE8标准,IE7标准和Quirks,元素A的offsetParent 取值是已定位的祖先元素; 3、当元素A的祖先元素级别中某祖先元素的position不是默认值(static),diplay为none,IE8标准下,元素A的offsetParent 取值是body元素,IE7标准和Quirks下返回的值仍是已定位的祖先http://www.w3dev.cn/article/20120412/offsetParent-attribute.aspx
来获取元素A。 其次,offsetParent 属性,这个属性在 MSDN 的文档中也没有解释清楚,这就让人更难理解这个属性。 以下是本人在网上查到的一些资料总结,需要的朋友可以参考一下: 要明白 offsetParent 属性,要先明白已定位元素这个名字,所谓已定位元素就是指给元素设置了 position 属性的样式,并且 position 样式属性的值等于 absolute、relative、fixed 之一的元素。 在使用 offsetParent 属性获取父级对象时有以下两种情况:1、元素本身已经定位 如果元素本身已经定位,那么 offsetParent 属性返回此元素已定位父http://www.w3dev.cn/article/20120412/parentElement-offsetParent-difference.aspx
var p = this.board.getElementsByTagName('table')[0]; while (p) { this.xy.x += p.offsetLeft; this.xy.y += p.offsetTop; p = p.offsetParent } } ChessBoard.prototype.createChesss = function (e) { if (this.end) { alert('已经得出输赢或者所有旗子已经下完!'); return;} var x =http://www.w3dev.cn/article/20160519/javascript-GO-Board.aspx
var thei = tt.clientHeight; //TT控件本身的高 var tleft = tt.offsetLeft; //TT控件的定位点宽 var ttyp = tt.type; //TT控件的类型 while (tt = tt.offsetParent ) { ttop += tt.offsetTop; tleft += tt.offsetLeft; } dads.top = (ttyp == image) ? ttop + thei : ttop + thei + 6; dads.left = tleft;http://www.w3dev.cn/article/20130106/meizz-calendar.aspx
function computeRange(o) {//获取对象范围 var p = { x: o.offsetLeft, y: o.offsetTop,x1:o.offsetWidth,y1:o.offsetHeight }; while (o = o.offsetParent ) { p.x += o.offsetLeft; p.y += o.offsetTop; } p.x1 += p.x; p.y1 += p.y; return p; } funhttp://www.w3dev.cn/article/20121214/javascript-get-dom-object-under-cover-layer.aspx
变过。再次更改css样式如下.ieexp{top:expression(document.title=this.offsetParent .scrollTop+'|'+this.offsetParent .tagName);left:0px;}页面标题栏显示实际的页面的滚动scrollTop属性|HTML,this.offsetParent 到底是什么可以参考 offsetparent ,设置为.ieexp{top:expression(this.offsetParent .scrollTop);left:0px;} 这次没问题了,在IE6可以滚动。 但是奇怪为什么直接设置成dohttp://www.w3dev.cn/article/20120412/IE-css-expression-scrolltop.aspx
算法。 如果元素 A 的 offsetParent 是 null 或者是 HTML 的 body 元素,以 CSS 像素为单位返回元素 A 上边框距画布原点的垂直距离,并停止本算法。 以 CSS 像素为单位返回元素 A 上边框距其 offsetParent 上边框的距离。在元素 A 上调用 offsetLeft 属性时,必须按以下算法返回结果值: 如果元素 A 是 HTML 的 body 元素,其 display 属性计算值是 none,或者不具有 CSS 布局盒子,则返回 0,并停止本算法。 如果元素 A 的 offsetParent 是 null 或者是 HTMLhttp://www.w3dev.cn/article/20120215/how-to-calculate-offsetTop-offsetLeft.aspx
'"+this.id+"').lock=false",1);}};MzPopupLayer.prototype.bind=function(trigger,width,height){vare=trigger,x=e.offsetLeft,y=e.offsetTop;while(e=e.offsetParent ){x+=e.offsetLeft;y+=e.offsetTop;}varDL,DT,top=0,left=0;if(window.pageXOffset){DL=window.pageXOffset;}elseif(document.documentElementdocument.dohttp://www.w3dev.cn/article/20110212/CreatePopup-showModalDialog-showModalessDialog.aspx
=false,ifY=false;//iframe的绝对位置window.onload=function(){varifr=document.getElementById('ifr');ifX=ifr.offsetLeft;ifY=ifr.offsetTop;while(ifr=ifr.offsetParent ){ifX+=ifr.offsetLeft;ifY+=ifr.offsetTop;}}/scriptb.htm+展开 -HTML获取iframe中鼠标事件在父页的坐标位置br获取iframe中鼠标事件在父页的坐标位置br获取iframe中鼠标事件在父页的坐标位置br获取iframe中鼠标http://www.w3dev.cn/article/20100714/2718.aspx
with offsetLeft, offsetTop and offsetParent implementations. If an object has no offsetParent , then its offsetLeft value must be 0 and its offsetTop value must be 0. If an object's offsetLeft value is 0 and its offsetTop value is also 0, then such object's offsetParent attribute must be null otherwihttp://www.w3dev.cn/article/20100702/2663.aspx
with offsetLeft, offsetTop and offsetParent implementations. If an object has no offsetParent , then its offsetLeft value must be 0 and its offsetTop value must be 0. If an object's offsetLeft value is 0 and its offsetTop value is also 0, then such object's offsetParent attribute must be null otherwihttp://www.w3dev.cn/article/20100702/2664.aspx
returnId;}function$s(Id,tag){return$(Id).getElementsByTagName(tag);}function$abs(o){varp=newObject();p.x=o.offsetLeft;p.y=o.offsetTop;while(o=o.offsetParent ){p.x+=o.offsetLeft;p.y+=o.offsetTop;}returnp;}/****缩略图片尺寸已经设好,为120x90,无法修改,并且注意大图和小图的名称就差“_s”,小图多“_s”。如大图为“12345.jpg”,则小图格式为“12345_s.jpg”***一些要http://www.w3dev.cn/article/20100617/2639.aspx
哪位大虾知道用js画形状比较特别的框?/divscript type=text/javascriptfunction getAbsolutePosition(o){//获取对象的绝对位置 var p={x:o.offsetLeft,y:o.offsetTop}; while(o=o.offsetParent ){ p.x+=o.offsetLeft;p.y+=o.offsetTop; } return p;}function showPopUp(){// var p=getAbsolutePosition(this),popDV=document.getElementById(&http://www.w3dev.cn/article/20100519/2422.aspx
ect relative to the layout or coordinate parent, as specified by the offsetParent property. offsetTopRetrieves the calculated top position of the object relative to the layout or coordinate parent, as specified by the offsetParent property. textSets or retrieves the text contained within the range.http://www.w3dev.cn/article/20100430/2305.aspx
._IsMid=true;}}else{this._IsMid=false;}},//鼠标点击控制ClickCtrl:function(e){varo=this.Container,iLeft=o.offsetLeft,iTop=o.offsetTop;while(o.offsetParent ){o=o.offsetParent ;iLeft+=o.offsetLeft;iTop+=o.offsetTop;}//考虑有滚动条,要用pageX和pageYthis.EasePos(e.pageX-iLeft-this.Bar.offsetWidth/2,e.pageY-iTop-this.Bar.ohttp://www.w3dev.cn/article/20091222/1222.aspx
ng"==typeofid?document.getElementById(id):id;};alert($("t").offsetParent )//bodyalert($("t1").offsetParent )//tdalert($("t2").offsetParent )//tablealert($("t3").offsetParent )//divalert($("t4").offsetParent )//null/script/body/html可见offsetParent 跟parentNode的区别还是很大的。而parentNode跟parentElement除了前者是w3c标准,后者只ihttp://www.w3dev.cn/article/20091222/1225.aspx
,display:"block",zIndex:99,margin:0,//避免定位问题left:"-9999px",top:"-9999px"//避免占位出现滚动条});//offset修正参数variLeft=0,iTop=0,p=this.tip;while(p.offsetParent ){p=p.offsetParent ;iLeft+=p.offsetLeft;iTop+=p.offsetTop;};this._offsetleft=iLeft;this._offsettop=iTop;//移入Tip对象时保持显示状态$$E.addEvent(this.tip,"mouseover",http://www.w3dev.cn/article/20091222/1226.aspx
39;+v+')');}//获取某个对象的绝对位置Showbo.getAbsPos=function(o,addXY){o=Showbo.$(o);var p=new Object();p.x=o.offsetLeft;p.y=o.offsetTop;while(o=o.offsetParent ){p.x+=o.offsetLeft;p.y+=o.offsetTop;}if(addXY){if(!isNaN(addXY.x))p.x+=addXY.x;if(!isNaN(addXY.y))p.y+=addXY.y;}return p;}Showbo.$=function(Id,http://www.w3dev.cn/article/20090907/ajax-asp-net-mssqlserver-no-refresh-chat-room.aspx
,谁知道后来竟然没有了。。后悔ing...请各位帮帮忙!!---------------------------+展开-JavaScriptfunctiongetOffsetXFF(evt){varo=evt.target;varx=0;while(o.offsetParent ){x+=o.offsetLeft;o=o.offsetParent ;}returnevt.pageX-x;}元素使用了 绝对定位或相对定位时 layerX === offsetX;lz将img设为 position:relative 即可http://bbs.51js.com/viewthread.php?tid=8http://www.w3dev.cn/article/20090729/612.aspx
ript"//![CDATA[functiongetAbsolutePosition(e){varwidth=e.offsetWidth;varheight=e.offsetHeight;varleft=e.offsetLeft;vartop=e.offsetTop;while(e=e.offsetParent ){left+=e.offsetLeft;top+=e.offsetTop;};varright=left+width;varbottom=top+height;return{'width':width,'height':height,'left':left,'top':top,'righttp://www.w3dev.cn/article/20090701/321.aspx
eft=e.clientX+element.document.body.scrollLeft;varcx=0,cy=0;varelCurrent=objDragItem.offsetParent ;while(elCurrent.offsetParent !=null){cx+=elCurrent.offsetTop;cy+=elCurrent.offsetLeft;elCurrent=elCurrent.offsetParent ;}objDragItem.style.pixelTop=intTop-cx-midHObj;objDragItem.style.pixelLeft=intLeft-cyhttp://www.w3dev.cn/article/20090629/241.aspx
kw'function/span getoffset(e) { span class='kw'var/span t=e.offsetTop; span class='kw'var/span l=e.offsetLeft; span class='kw'while/span(e=e.offsetParent ) { t+=e.offsetTop; l+=e.offsetLeft; } span class='kw'var/span rec = span class='kw'new/span Array(1); rec[0] = t; rec[1] = l; span clahttp://www.w3dev.cn/article/20090604/70.aspx
性 boundingHeight 获取绑定TextRange对象的矩形的高度 boundingLeft 获取绑定TextRange 对象的矩形左边缘和包含TextRange对象的左侧之间的距离 offsetLeft 获取对象相对于版面或由offsetParent 属性指定的父坐标的计算左侧位置 offsetTop 获取对象相对于版面或由offsetParent 属性指定的父坐标的计算顶端位置 htmlText 获取绑定TextRange对象的矩形的宽度 text 设置或获取范围内包含的文本 getClientRects() 返回 TextRange 对象包含的每一行的矩形信息方法 moveStahttp://www.w3dev.cn/article/20090603/62.aspx
首页 上一页 [1] 下一页 尾页 1/1页,每页显示30条,共23条相关记录