wonderfan / javascript

Explore the power of HTML,CSS and JavaScript
1 stars 0 forks source link

CSS Positioning #27

Closed wonderfan closed 9 years ago

wonderfan commented 9 years ago

The CSS positioning properties allow you to position an element. It can also place an element behind another, and specify what should happen when an element's content is too big.

Elements can be positioned using the top, bottom, left, and right properties. However, these properties will not work unless the position property is set first. They also work differently depending on the positioning method.

wonderfan commented 9 years ago

HTML elements are positioned static by default. A static positioned element is always positioned according to the normal flow of the page.

Static positioned elements are not affected by the top, bottom, left, and right properties.

wonderfan commented 9 years ago

An element with a fixed position is positioned relative to the browser window, and will not move even if the window is scrolled:

wonderfan commented 9 years ago

Note: IE7 and IE8 support the fixed value only if a !DOCTYPE is specified.

wonderfan commented 9 years ago

Fixed positioned elements are removed from the normal flow. The document and other elements behave like the fixed positioned element does not exist.

Fixed positioned elements can overlap other elements.

wonderfan commented 9 years ago

A relative positioned element is positioned relative to its normal position:

wonderfan commented 9 years ago

The content of relatively positioned elements can be moved and overlap other elements, but the reserved space for the element is still preserved in the normal flow.

wonderfan commented 9 years ago

Relatively positioned elements are often used as container blocks for absolutely positioned elements.

wonderfan commented 9 years ago

An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is :

wonderfan commented 9 years ago

Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the absolutely positioned element does not exist.

Absolutely positioned elements can overlap other elements.