Review the front-end basics-css float and clear float, and review the front-end-css float

Source: Internet
Author: User

Review the front-end basics-css float and clear float, and review the front-end-css float

What is the concept of Document Stream? In which way can elements be moved out of the Document Stream?

  • Document Stream refers to the stream arrangement in which elements are automatically arranged from left to right and from top to bottom during element layout. Finally, the form is divided into rows from top to bottom, and elements are discharged from left to right in each row. If you leave the Document Stream, the elements disrupt the arrangement or take it away from the layout.
  • Elements can be moved out of the document stream through floating and locating.

In CSS, the float attribute is used to float elements.

A floating box can be moved to the left or right until its outer edge hits the border of the contained box or another floating box.

Because the floating box is not in the normal stream of the document, the block box in the normal stream of the document performs as if the floating box does not exist.

The following are the effects of floating elements.

 

Clear floating refers to: In a non-IE browser (such as Firefox), when the container has a fixed height and the container content contains floating (float is left or right) elements, in this case, the height of the container cannot be automatically extended to adapt to the height of the content, so that the content overflows outside the container and affects the layout, to prevent the occurrence of this phenomenon, CSS processing is called clearing the float.

One of the methods to clear the floating:

Using the clear attribute, clear has three attribute values: left, right, both, none, inherit.

1. Use an empty element with the clear attribute

2. Use a pseudo element and clear: both in the pseudo element;

3. Add overflow: hidden or overflow: auto to the parent element. In addition, hasLayout needs to be triggered in IE6. For example, set the container width and height for the parent element or set zoom: 1.

 

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.