Positioning in HTML

Source: Internet
Author: User

The positioning system in HTML

First, classification

1. Conventional flow static

2. Float float

3. Relative positioning relative

4. Absolute positioning Absolute

5 Fixed positioning

Second, the use of the distinction

In the layout of the Web page, it is often used in the 5 positioning method, the overall divided into three categories: static, floating float, absolute positioning (relative, absolute, fixed).

1. The default value is static

2. Float float

2 Questions to keep in mind when using a floating layout

1. Float causes the parent element to collapse highly

2. BFC Block Formatting context

* BFC can solve the problem of high collapse, with clear or overflow attribute to solve overflow not equal to hidden then create a BFC

The difference between clear:both and overflow

Clear to determine that external elements affect their layout

Overflow determine if the element affects the layout of the page

3. Absolute positioning

1. Relative positioning

Relative positioning retains the position in the regular flow, and the relative positioning of the actual coordinates in the original position, when relative positioning is used, the other elements are overwritten.

2. Absolute positioning

Absolute positioning does not retain a position in the regular stream, and when used, note the location of the origin (the ancestor element position is not equal to static), and if there is no such element, then the origin is the origin of the HTML containing block

3. Fixed position

Fixed positioning does not retain a position in the regular stream, the coordinates are the starting point for the current viewport

Third, in the normal site layout, a variety of layouts will be used, according to their actual situation specific use of different layouts.

Positioning in HTML

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.