CSS positioning, position and float simultaneous use of the situation

Source: Internet
Author: User

First, CSS positioning

There are three basic positioning mechanisms for CSS: normal flow, floating, and absolute positioning.

1. Normal flow: Elements not specifically specified are located in the normal flow, position:static/relative; and Float:none; also located in the normal flow.

2. Absolute positioning: position:absolute/fixed; element box out of normal document flow.

3. Floating: Float:left/right; element out of normal document flow.

Second, the use of position and float in the case of the elements

The practice found that both position and float who write in front or behind, are position first function.

1. When position is absolute/fixed, the element is detached from the document stream, and the element is applied with float invalidated (that is, does not work).

2. When position is static/relative, the element is still in the normal stream, and the element is applied to float.

  

The difference between the absolute positioning mechanism and the floating positioning mechanism of the CSS positioning mechanism

1. After position the element out of the normal stream, the element does not occupy space and uses top/bottom/left/right to determine the position.

2. When the element is separated from the normal stream with float, the element occupies space , determines the distance from the surrounding content with margin,padding, and so on.

(The text for learning Exchange, welcome to explore together ~)

CSS positioning, position and float simultaneous use of the situation

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.