CSS parent class clear floating reason

Source: Internet
Author: User
Floating factors are often applied to static Web pages, for example, to allow block-level elements to be exclusive to one line, often using the float method. However, when applied, it is found that when the subclass floats, the parent class is not cleared to float, which causes the problem:

1. Floating elements will float relative to the parent container or the previously positioned elements, floating elements out of the document flow, i.e. no longer occupying the original position, affecting subsequent elements or the parent container .

2. The parent container normally expands automatically, but the child element is not preserved when it is added to the floating position, and the parent container feels that it does not exist, so it does not widen.

Therefore, when writing a static Web page, be sure to pay attention to the floating cleanup problem, a clear floating code can be easily called:

. clearfloat:after{content: ';                Display:block;                height:0;          Visibility:hidden;} . clearfloat{Zoom:1;}
Related Article

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.