CSS Clear Float

Source: Internet
Author: User

function: achieve picture and text mixed effect

principle: Absolutely positioned elements are out of the document flow, while floating elements are still in the document flow;

Clear float: ( height collapse)

1. Additional labeling method, <div style= "Clear:both;" ></div> (Cons: But this approach adds extra tags to make the HTML structure look less concise.) )

2. Use the after pseudo-element (the method must set height:0 in a pseudo-object that needs to clear the floating element, otherwise the element will be a few pixels higher than the actual)

#parent {zoom:1}

#parent: after{

Content: ".";

height:0; line-height:0;

Visibility:hidden;

Display:block;

Clear:both;

}

3. Overflow + Zoom method (Zoom, IE unique properties, similar to zoom)

. Fix{overflow:hidden; zoom:1;}

(The problem is this overflow:hidden, it is a small fried egg, if the elements in the inside if you want a margin negative positioning or negative absolute positioning, it is not directly cut off, so this method has no small limitations. )

CSS Clear Float

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.