The best CSS position property Tutorial In 2024, In this tutorial you can learn Examples,Attribute definitions and instructions,Browser Support,Property Value,More examples,related articles,

CSS position property

Examples

Location <h2> element:

h2
{
position: absolute;
left: 100px;
top: 150px;
}



In the bottom of this page for more examples.

Attribute definitions and instructions

Position attribute specifies the type of an element (static, relative, absolute or fixed) positioning method.

Defaults: static
inherit: no
version: CSS2
JavaScript syntax: object .style.position = "absolute"


Browser Support

Figures in the table represent the first browser to support the version number of the property.

属性
position 1.0 7.0 1.0 1.0 4.0

Property Value

value description
absolute

Generate absolute positioned elements, relative to the first parent element positioned outside the static positioning.

Position of the element by the "left", "top", "right" and "bottom" attribute specified.

fixed

Generate absolute positioning of elements relative to the browser window positioning.

Position of the element by the "left", "top", "right" and "bottom" attribute specified.

relative

Generating element relative positioning, positioning relative to its normal position.

Thus, "left: 20" adds 20 pixels to the element's LEFT position.

static Defaults. No positioning element occurs in normal flow (ignoring the top, bottom, left, right or z-index statement).
inherit Provisions should inherit the property value position from the parent element.


Examples

More examples

Position: relative
This example demonstrates an element relative to its normal position, how to locate.


related articles

CSS tutorial: CSS Positioning

CSS position property
10/30