CSS Float float

Source: Internet
Author: User

Daily cut layout often used to float, but will only use but do not know the principle of floating, clear the role of floating.

Today we will explain the basic functions and principles of floating, clear the floating of those methods, daily development usually with what clear floating.

First, what is floating?

Moves an element out of the document stream, moving in a specified direction, encountering a parent boundary, or stopping adjacent floating elements.

Ii. What is a document flow?

A document flow is the position in the document where objects are placed in the arrangement, from top to bottom, from left to right, by default.

Third, why to use floating?

The layout will have two div side-by display, without changing the div element attributes, using floating to make the most convenient implementation method.

Float:left | Right | none | Inherit

Iv. the role of floating

1, block in a row display

2. Make the inline support wide and high

3, the default content open width

4. Out-of-document flow

5. Upgrade the level half layer

V. Methods of clearing floating

1. Heightening problem: Poor extensibility

2. Parent floating problem: all elements in the page are floating, margin is automatically invalidated (floats bad!). )

3.inline-block Clear Floating Method: problem: Margin left and right automatic failure;

4. Empty label Clear floating problem: IE6 minimum height 19px; (2px deviation after solution IE6)

5.br floating problem: Not in line with the work: structure, style, behavior, three separate requirements.

6.after pseudo-Class clear floating method (now the mainstream method). Clear:after{content: ";d isplay:block;clear:both;}. Clear{zoom:1;} after Pseudo-class: add content at the end of the element: After{content "added content";} ie6,7 is not compatible with zoom zoom A, trigger ie under haslayout, so that the element according to its own content to calculate the width of high. B, FF does not support;

7.overflow:hidden clear Floating method; problem: need to match width or zoom compatible IE6 IE7; Overflow:scroll | Auto | hidden; overflow:hidden; overflow hide (cutter!) )

The most common after pseudo-class clears floats.

CSS Float float

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.