General flow CSS positioning mechanism

Source: Internet
Author: User
Tags format definition reference relative

Web page Production WEBJX article introduction: not finding a complete set of Chinese articles about ordinary flow, floating, and absolute positioning, so he took the courage to decide to write a piece. To do this roughly chewed out the CSS2.1 8 box model and 9 Visual formatting model. To tell the truth, I really see a little head big, hehe ~ document flow, in fact, there is no standard in the word. If you translate the document literal

Not finding a complete set of Chinese articles about ordinary flow, floating, and absolute positioning, so he took the courage to decide to write a piece. To do this roughly chewed out the CSS2.1 8 box model and 9 Visual formatting model. To tell you the truth, I really see a little head, hehe ~

Document flow, in fact, there is no such word in the standard. If you translate a document into English, it is document flow, but there is only one other word in the standard, called a normal flow, or a regular stream. But it seems that everyone is more accustomed to the name of the document flow, because many Chinese translation of the book is so. For example, "CSS mastery", the original book from the beginning to the end of the only normal flow of the word, never appeared document flow documents. But the Chinese version of "Normal Flow" and "document Flow" are alternating.

What is a normal stream? Simply put, the element determines the arrangement of the elements in the order in which they are placed in the HTML. And this process follows the standard description.

To illustrate this from different angles, I have taken some definitions that may be lengthy, specific, or obscure to others:

Divides the form from top to bottom, and emits the elements in a left-to-right order in each row, which is the document flow. Normal flow is how elements are rendered on a Web page in most cases. All HTML is in a block-boxes, block-level element, or inline box (inline boxes, inline element).

Rainbo Design: When the browser starts rendering the HTML document, it starts at the top of the window and, through the entire document content, allocates the space needed for the element. Unless the size of the document is specifically restricted by CSS, the browser expands the document vertically to accommodate all of the content. Each new block-level element is rendered as a new row. Inline elements are rendered horizontally in order until the current row encounters a boundary and then the next line of vertical rendering. This process is a normal document stream.

As you can see, the flow is understood as a flow, completely speaking. A normal flow is an element arrangement and positioning process in general.

But in fact, in CSS2.1RC, the essence of ordinary flow is one of three kinds of localization mechanisms (positioning schemes), which is defined as:


Normal flow. In CSS 2.1, normal flow includes blocks formatting of block boxes, inline formatting of inline boxes, relative positioning of block or inline boxes, and positioning of run-in boxes.

This process consists of block formatting (blocks formatting), inline formatting (inline formatting), relative positioning (relative positioning), and run-in boxes positioning. Seem very different from those above, but to break it down is still consistent.

In addition, 9.4 Normal flow also has a paragraph:


Boxes in the normal flow belong to a formatting context, which may is block or inline, but not both simultaneously. Block boxes participate the formatting context. Inline boxes participate in a Inline formatting context.

This is a description of the paragraph, not a definition. box in the normal stream is a formatting context (format) in which the type can be block or inline, but not both. Also, the Block boxes (box) is formatted in the Block-formatting context (chunk format), Inline boxes (block inner box) is formatted in the Inline formatting context (in-line formatting contexts) Of.

We know that any element that is being rendered belongs to a box and is not block or inline. Even text that is not wrapped by any element, according to different circumstances, will also belong to the anonymous block boxes or inline boxes. So the above description, that is, all the elements are divided into the corresponding formatting context.

Combining the above definition, and let's say that the formatting context is a scoping, then in particular, the ordinary flow is such a process:

1. In the corresponding blocks formatting context, the block-level elements in the order of their HTML, in their container box from the top left corner, from top to bottom of the vertical allocation of space, stack (stack), and exclusive line, the boundary close to the parent container. Two the distance between adjacent elements is determined by the margin property, and the vertical boundaries in the same block formatting context are overlapped (collapse). Also, the width of block-level elements is not affected by floating elements unless a new formatting context is created (which is why floating elements can be covered above block-level elements).

2. In the corresponding inline formatting context, the inline elements start at the top of the container and are arranged horizontally one after another. Horizontal fills, borders, and margins are valid for inline elements. But vertical fills, borders, and blank edges do not affect their height. All inline boxes in a horizontal row make up the rectangular area named Line box. Line box's height always has all the inline box, and is only related to the row height. The width of line box is affected by the presence of the parent container and the floating element (this is the text wrapping the floating element). If line box is less than the width of the container, line box's horizontal arrangement depends on the text-align. If line box is wider than the container, truncate lines box and wrap the elements in the new row box (padding and margin values are not applied at the truncation). If line box cannot be truncated, such as a word that is too long or specifies no wrapping, the container overflows.

[1] [2] [3] Next page

Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.