Floating some points of knowledge

Source: Internet
Author: User

One, floating definition: will be forced to change the display for Inline-block, so that the element queue column, (arrangement by the property value, LEFT/RIHGT), so that the element is semi-detached document state

Second, floating elements in the semi-floating state, can see the floating elements of the main text and have inline attributes of the elements, so this raises a problem, and an application

(1) One problem: parent container cannot see child floating elements

Workaround:

Method one: Departure CSS hack, change the rendering rules, the common method is as follows:

Overflow:hidden;

Position:absolute;

Display:inline-block;

Method Two (most standard method): After pseudo-element clears the float (note: ie6,7 is not compatible with pseudo-element processing, *IE6, 7 can identify, _ only IE6 can be identified)

            

<div class= "wrapper" >        <div class= "content" ></div>        <div class= "content" ></div >        <div class= "content" ></div>    </div>

. wrapper {    width:1000px;    Background-color:pink;    *zoom:1; /* Resolve IE6, 7 incompatible pseudo-element issues */}.content {    float:left;    width:200px;    height:200px;    Background-color:orange;}

(2) An application: Achieve the text wrapping effect of the picture

The normal text is aligned with the bottom of the picture, and by setting the picture float allows the text to be aligned from the top of the picture, enabling text to surround the image, like a newspaper layout

img {    float:left;/* or right*/          }

    

Floating some points of knowledge

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.