Resolves a problem where the height of the parent element of float floats is not---clear floating

Source: Internet
Author: User


Properties of float:

1: Make the element block level;


2: The tight permutation characteristic caused by the destructive.


based on the above characteristics, so that we usually put the float to the layout, the problem is that it is prone to problems, reusability, ie6-version of a lot of issues, because it is required fixed width, the width calculation error will bring the entire layout of the confusion.
The Float property is originally intended to allow text to be wrapped around the picture to achieve the effect of the image and the flow layout, so the height of the parent element of float floats is not the problem we are talking about is a BUG, which in itself is the property of float.


here is the problem of resolving the height of the parent element caused by float floatTest for ie5+
1: Add a style to Clear:both after the floating element inside the parent element; The disadvantage is the addition of useless tag elements;
. clear{Clear:both; height:0px; font-size:1px; line-height:0px;overflow:hidden;} /* Clear FLOAT */


2: Add a pseudo-class to the parent element and give the style (. Fix on the parent element that contains the floating child element)
. Fix:after{content: "";d Isplay:block;height:0;overflow:hidden;clear:both;}
. Fix{*zoom:1;} Compatible with IE7 below
Or
. Fix:after{content: ""; Display:table; clear:both;}
. Fix{*zoom:1;}


3: Add a sentence directly to the parent element:
Parent element {Overflow:hidden;}

Resolves a problem where the height of the parent element of float floats is not---clear floating

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.