Understand floating elements-how to use them, what their problems are, and how to solve these problems.

Source: Internet
Author: User


Elements that need to be floated can use the Float property in the CSS to define the floating position of the element, left: floating to the right.
Issues caused by floating elements:
(1) The height of the parent element cannot be stretched, affecting elements that are siblings of the parent element
(2) A non-floating element that is similar to a floating element follows
(3) The element before the element also needs to float, otherwise it will affect the structure of the page display, unless the first element floats
Workaround:
Using Clear:both in CSS, properties to clear the floating of elements can solve 2, 3 problems, for problem 1, add the following style to the parent element to add the Clearfix style:
. Clearfix:after{content: "."; Display:block;height:0;clear:both;visibility:hidden;}
. Clearfix{display:inline-block;} /* for IE/MAC */

Understand floating elements-how to use them, what their problems are, and how to solve these problems.

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.