Clear float impact and clear floating float impact

Source: Internet
Author: User

Clear float impact and clear floating float impact

Floating will cause the parent element to collapse:

Solution:

Parent element overflow: hidden,

Insert the child element clear at the end,

Why does parent element overflow: Den den solve the collapse problem?

From zhihuTaobaoxiangAnswer

Overflow: hidden indicates that the excess part must be cropped and hidden.

If the float element does not occupy the normal stream position, the inclusion block of the normal stream must be cropped and hidden Based on the Content height.

If the height is the default value auto, You can crop it without calculating the floating element height.

It is possible to cut off float, which is a common sense of anti-layout.

----------------------------- Split line -------------------------------------

If you understand the problem of BFC, you can solve it. Let's see what BFC says.

In the BFC layout specification, when calculating the BFC height,Floating elements are also involved in calculation.

Overflow: hidden creates BFC.

Why does inserting the child element clear at the end solve the collapse problem?

Let's take a look at what is clear about floating. This problem can also be solved.

From official documents:

If it is declared to be clear on the left or right side, the upper and outer border borders of the element will be on this side.Bottom margin of floating Element.

OK, a good foundation will go further.

 

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.