CSS Visual format model (CSS Mastery essay)

Source: Internet
Author: User

When CSS renders a page, consider each document element as a box.

CSS Box model

Margin,padding,border, content.

Margin will appear margin folded. The margin of the upper and lower elements is collapsed. Left and right do not fold. The marign between the contained elements is also collapsed. The advantage of margin folding is that the document is neatly formatted.

Each element will have a box. There are two types of this box. Block-level elements of the block box, inline elements within the inline box.

Line box: There is also the concept of a line box, where the height of the row box is determined by the middle tallest inline box. Setting the height, padding, margin of the inline box does not affect the height of the row box. The height of the line box line-height to set the row height.

Anonymous box. Anonymous box is not easy to set style (: First-line)

  

There are three rendering models of CSS.

Natural document flow, position, float.

float: Floating element out of document flow. Can float on the left and float right. Floating out of the document stream, block elements ignore floating elements, natural typography, however, the elements inside the block element are unaware of the floating existence of the text elements around the floating layout. You can use clear to clear the float.

The parent element height of the float element is 0.

1, add label, clear float.

2,overflow

3, parent element float

The 4,after element.

Postion

Relative: Also in the natural flow, the position offset in the relative natural flow.

Absolute: In the natural flow, the relative position is set to the ancestor element of relative,absolute,fixed, if not the initial containing block.

Fixed: Relative window positioning.

CSS Visual format model (CSS Mastery essay)

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.