The topic was intended to be modified as "closed floating element" or "clear floating element", but if you think about it, it's better not to change it. Because from this topic we can easily see that if you do not close (clear) floating elements, it will be the result of the-----div height can not automatically increase.
Anyway Currently used to clear the "closed (clear) floating" method, mainly four:
1. Additional Labeling method
This method is to insert an extra label at the end of the parent container and make it clear the float to support the parent container. This approach is good for browser compatibility, there is no problem, the disadvantage is that the need for additional (and usually no semantic) tags. I personally do not like this method, but it is indeed the recommended method of the Consortium
<div style= "Clear:both;" ></div>
or use
<BR style= "Clear:both"/>
2. Use after pseudo class
This approach is to add new content to the parent container using the after pseudo class and content declaration at the end of the specified current content. It is often done by adding a "dot" because it is less noticeable. Then we use it to clear the float (closed floating element) and hide this content. This method of compatibility, but through a variety of hack can also cope with different browsers, but also to ensure that the HTML is relatively clean, so use is still more.
The practice is to set the parent container's overflow to hidden or auot to close the floating element in a standard-compatible browser. However, when using overflow, it may affect the performance of the page, and this effect is uncertain, you'd better be able to test your page in multiple browsers
4. Floating external elements, float-in-float
This approach is to allow the parent container to also float, which leverages an attribute of the floating element-the floating element closes the floating element. This way in Ie/win and standard-compatible browsers have a good effect, but the disadvantage is also obvious--the parent container may not want to float on the float, after all, floating is a special behavior, sometimes the layout does not allow its floating is also very normal. The individual is not very much in favor of this practice, but from the Dudo final summary can always see that he seems to agree with this approach
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.