CSS clear Float Common method

Source: Internet
Author: User

CSS development process clear floating is difficult to avoid to use, today sacrificed nap time to tidy up!

One, to the parent to add height: This certainly does not exist in the parent collapse problem;

Problem: Extensibility is not good, if you want to adapt to the height of the sad urge.

Second, let the parent float: the parent and the child are floating there is no problem;

Problem: All elements in the page are floating, margin is automatically invalidated (floats bad!) ),

Besides, all the parents can float, and there are extensibility issues.

Third, to the parent plus display:inline-block clear Floating method:

Problem: Automatic failure of margin around;

Four, empty label clear floating

add <div class= "clear" under floating elements ></div>
. clear{Height:0px;font-size:0;clear:both;}add <br clear= "All" under floating elements/>

Problem: IE6 Minimum height 19px, (after solving IE6 and 2px deviation), does not conform to the work: structure, style, behavior, three separate requirements.

Five, after pseudo-class clear floating method (now the mainstream method)

. Clear:after {
content:";
  Display:block;
  Clear:both;
}. Clear{
Zoom:1;
}

After pseudo-class: add content at the end of the element;

: after{content "added content";} Incompatible under ie6,7

Zoom Scale

A, trigger IE under the haslayout, so that the elements according to their own content to calculate the width of high.

B, FF does not support;

CSS clear Float Common method

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.