CSS Positioning (Position)

Source: Internet
Author: User

Static positioning

The default for HTML elements, that is, no positioning, elements appear in the normal stream.

Statically positioned elements are not affected by top/bottom/left/right

Fixed positioning

The position of the element relative to the browser window is a fixed position.

Does not move even if the window is scrolled

This means that the fixed element position is relative to the browser window.

Attention:

Fixed positioning under IE7/IE8 needs to be described! DOCTYPE to support it.

Fixed positioning makes the position of an element independent of the document flow and therefore does not occupy the document flow space .

Fixed positioned elements overlap with other elements.

Relative positioning

Relative positioning elements are positioned relative to their normal positions. Such as:

Html:

<Divclass= "Panel">1</Div><Divclass= "Panel">2</Div><Divclass= "Panel">3</Div><Divclass= "Panel PL">4</Div><Divclass= "Panel">5</Div>

Css:

. panel{height:50px;border:1px dashed Red;width:200px;background-color: #ccc;}. pl{position:relative;left:100px;//relative to the original position to the right 100pxtop:30px;//relative to the original position downward 30pxbackground-color: #808080;}

Effect

It is important to note that the elements that define the relative are still occupied by the original space, and the elements overlap above other elements after the definition relative.

Relative positioning elements are often used as container blocks for absolutely positioned elements

Absolute positioning

The position of an absolutely positioned element is relative to the nearest parent element, if the element has no positioned parent element, then its position is relative to the

Absoulte positioning makes the position of an element independent of the document flow, so it does not occupy space and can overlap other elements

CSS Positioning (Position)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.