A deep understanding of the clear element in CSS

Source: Internet
Author: User
Clear:left; Indicates that there cannot be a floating element on the left.

Clear:right; indicates that the right side cannot have floating elements.
Clear:both: There is no floating element on either side.

However, when you use it, you also have to consider CSS precedence issues. The style developed by the same type selector, in the style sheet file, the higher the precedence.

  When the clear property of all elements is set to right, the reason for precedence is not what you think: There are no floating elements on the left, but floating elements appear on the right.

For example, the following code:



Clear-right

Where: Class-priority relationship: P5>P4>P3>P2>P1

So, it shows the situation:

  

  When the clear property of all elements is set to left, the reason for precedence is not what you think: the right side can have floating elements, but not floating elements on the right.

For example, the following code:



Clear-left

Where: Class-priority relationship: P5>P4>P3>P2>P1.

So, it shows the situation:

I sometimes get dizzy occasionally. Anyway, understanding the CSS priority problem is easy to understand.

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.