CSS (v) floating

Source: Internet
Author: User

Main content of this chapter
    • What is floating?
    • How to float
    • Floating side effects and how to remove side effects
    • Usage Scenarios
first, float (float)

Meaning: Let the elements float, arranged side by side;

second, how to float
    • Float:left 1, 2, 3
    • Float:right attention to use in reverse order ... 3, 2, 1
    • Float:none not floating
    • Float:inherit inherit parent element floating mode

Note: Once the element has a floating property, it is automatically converted into block-level elements;

third, side effects

child element Floats, parent element collapses

The surrounding elements will be affected such as: floating elements out of the document flow, the other non-floating elements occupy the position of the floating elements, floating elements will float on the top of the floating element;

iv. addressing side effectsA, resolving the parent element collapse problem

A.1, adding a height to the parent element

A.2, parent element add two attributes

    • Overflow:hidden
    • Zoom:1

A.3, the parent element also gives a float, is not recommended to use, the surrounding elements will produce side effects;

B, to solve the problems affecting the surrounding elements

B.1, add an empty element to set the Clear method

    • Clear:none not floating
    • Floating elements are not allowed on the left side of Clear:left
    • Floating elements are not allowed on the right side of Clear:right
    • Floating elements are not allowed on both sides of Clear:both
C, recommended combination using A.2 and B.1

v. Use of the sceneA, Text wrapping

Brothers for text text does not need to float, floating is not a sibling element of the text, you can achieve text wrapping.

........

CSS (v) 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.