What I know about BFC

Source: Internet
Author: User

BFC: block formatting context, also known as the block formatcontext, is a concept in the W3C CSS 2.1 Standard and is changed to flow root in css3. Formatting indicates that the elements in this environment should be initialized, that is, how to layout the elements in this environment. If a BFC element is created, BFC determines how to locate its content and its relationship and interaction with other elements. Elements that have created BFC are arranged as follows:

1. child elements of an element are placed one by one. In the vertical direction, their starting point is the top of a block. The vertical distance between two adjacent elements depends on the 'margin 'feature. The vertical margin of adjacent block-level elements in BFC is collapsed (collapse ).

2. in the child element of an element, the left outer side of each child element is in contact with the left side of the contained block (for formatting from right to left, the right outer side is in contact with the right side ), this is true even if there is a floating (although the content area of a child element is compressed due to floating), unless this child element also creates a new BFC, such as it is also a floating.

Under what circumstances will BFC be created?

 

The CSS specification specifies that a new block formatting context will be created in the following cases:

 

1. Floating element (float: Left | right );

2. Absolute position element (position: absolute | fixed );

3. Line block elements (display: inline-block );

4. Table cells (display: Table-cells, TD, th );

5. Table title (display: Table-captions, caption );

6. The 'overflow' feature is not a visible element (unless the value has been propagated to the viewport ?);

7. "anonymous box" created by Table Elements"

MAIN FEATURES OF BFC

BFC is mainly used to clear float and implement multi-column layout.

 

In IE6 IE7 IE8 (Q), there is only the haslayout feature, but there is no BFC concept. The IE6-7 uses the concept of layout to control the size and positioning of elements, and those with the layout (has layout) are responsible for the size setting and positioning of themselves and their child elements. If the haslayout of an element is false, its size and position are controlled by the ancestor element with the most recent layout.

To be compatible with IE8-, either BFC and haslayout must be started at the same time or both

 

 

 

 

 

 

 

 

 

What I know about BFC

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.