top Attribute | top Property Internet Development Index --------------------------------------------------------------------------------Sets or retrieves the position of the object relative to the top of the next positioned object in the document hierarchy. SyntaxHTML { top : sTop }
Scripting object.style.top [ = sTop ] Possible ValuessTop Variant that specifies or receives one of the following values:auto Default. Default position according to the regular HTML layout of the page.
length Floating-point number, followed by an absolute units designator (cm, mm, in, pt, pc, or px) or a relative units designator (em or ex). For more information about the supported length units, see CSS Length Units Reference.
percentage Integer, followed by a percent sign (%). This value is a percentage of the height of the parent object.
The property is read/write for all objects except the following, for which it is read-only: currentStyle. The property has a default value of auto. The Cascading Style Sheets (CSS) attribute is not inherited. Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.ResThe top attribute should be used only when the position attribute is set; otherwise, the value of the top attribute is ignored.Because the value of the top property is a string, you cannot use the property in script to calculate the position of the object in the document; instead, use the pixelTop or the posTop property.For more information about how to access the dimension and location of objects on the page through the Dynamic HTML (DHTML) Document Object Model (DOM), see Measuring Element Dimension and Location.ExamplesThe following examples use the top attribute and the top property to change the position of the object.
This example uses an inline style to set the position of a div object.<DIV STYLE="position:absolute;top:100px">
. . . </DIV>
Scripting object.style.top [ = sTop ] Possible ValuessTop Variant that specifies or receives one of the following values:auto Default. Default position according to the regular HTML layout of the page.
length Floating-point number, followed by an absolute units designator (cm, mm, in, pt, pc, or px) or a relative units designator (em or ex). For more information about the supported length units, see CSS Length Units Reference.
percentage Integer, followed by a percent sign (%). This value is a percentage of the height of the parent object.
The property is read/write for all objects except the following, for which it is read-only: currentStyle. The property has a default value of auto. The Cascading Style Sheets (CSS) attribute is not inherited. Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.ResThe top attribute should be used only when the position attribute is set; otherwise, the value of the top attribute is ignored.Because the value of the top property is a string, you cannot use the property in script to calculate the position of the object in the document; instead, use the pixelTop or the posTop property.For more information about how to access the dimension and location of objects on the page through the Dynamic HTML (DHTML) Document Object Model (DOM), see Measuring Element Dimension and Location.ExamplesThe following examples use the top attribute and the top property to change the position of the object.
This example uses an inline style to set the position of a div object.<DIV STYLE="position:absolute;top:100px">
. . . </DIV>
解决方案 »
- js window.open() 急 在线等~
- jquery插件之ingrid问题请教
- 关于onmouseover onmouseout的疑惑
- 正在提交表单数据,请稍侯 ......
- 我在A 页放了个iframe,此iframe的SRC是B页。我要点击A页的一个按纽刷新A页里的iframe?怎么实现呢
- 输入框如何通过脚本语言来控制读写
- 原创 WEB版图片搜索下载程序
- http://61.139.8.44/gr/personqueryjobwillBycombon.asp帮忙实现上面的分页吧。
- 超急!!!如何将字符串变量转为数字变量??
- cocos2d-js中怎么删除一个精灵(可以定位坐标)
- 打印!
- 问一个包含的问题
Possible ValuesoTop Object that receives the topmost parent window. The property is read-only. The property has no default value.Standards InformationThere is no public standard that applies to this property.
Possible ValuesiCoord Integer that specifies or receives the top coordinate of the rectangle, in pixels. The property is read/write. The property has no default value.Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.ResUse this syntax to access the top coordinate of the second text rectangle of a TextRange object: oRct = oTextRange.getClientRects();
oRct[1].top;Note that the collection index starts at 0, so the second item index is 1.To access the top coordinate of the bounding rectangle of an object, use this syntax:oBndRct = oElement.getBoundingClientRect();
oBndRct.top;ExampleThis example uses the getBoundingClientRect method to retrieve the coordinates of the bounds of the text rectangles within the element.HideExample<SCRIPT>
function getCoords(oObject) {
oBndRct=oObject.getBoundingClientRect();
alert("Bounding rectangle = \nUpper left coordinates: "
+ oBndRct.left + " " + oBndRct.top +
"\nLower right coordinates: "
+ oBndRct.right + " " + oBndRct.bottom);
}
</SCRIPT>
</HEAD>
<BODY>
<P ID=oPara onclick="getCoords(this)">