B.118. top

This property lets you set the distance between the top edge of an absolute positioned element (including its padding, border, and margin)[13] and the top edge of the positioning context in which it resides. The positioning context is the content area of the element's nearest ancestor that has a position property value other than static, or the body element.

[13] The CSS2 specification contains an error that suggests that the padding, border, and margin of the positioned element should not be considered. This has been acknowledged as a mistake by the CSS Working Group in the Errata document for CSS2.

For relative positioned elements, this property sets a relative offset from the normal position of its top edge. So, a setting of 10px will shift the top edge of the box 10 pixels downward, and a setting of -10px will shift it 10 pixels upward.

Inherited: No

See also: Section B.90position, Section B.20bottom, Section B.55left, and Section B.93right

B.118.1. Value

A CSS length measurement, a percentage value, or the auto constant. Percentages are based on the height of the parent element. The auto constant tells the browser to determine the position of the top edge itself, based on whatever other constraints may exist on the size/position of the element.

Initial value: auto

B.118.2. Compatibility

CSS Version: 2

Supported by all CSS-compatible browsers, including Internet Explorer 4 or later, Netscape 4 or later, and Mozilla browsers.

B.118.3. Example

This style rule positions the element with ID menu 10 pixels from the top edge of the window:

#menu {
  position: absolute;
  top: 10px;
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.85.33