Block element
Basic box
CSS assumes that each element generates one or more rectangular boxes, called element Marina. The center of each element box has a content area surrounded by an optional inner margin, border, and margin. The background of the content is also applied to the padding, the margins are usually transparent, from which you can see the background of the parent element, the padding cannot be negative, and the margin can be.
Border if no color is set, the foreground color will be taken, the width must never be negative
Include Block
Each element is placed relative to the containing block, and the containing block is composed of the content boundaries of the nearest block-level ancestor box, table cell, or inline block ancestor box.
Horizontal formatting
7 Large properties for horizontal formatting: margin-left,border-left,padding-left,width,padding-right,border-right, Margin-right. The values of these 7 attributes must be combined with the width of the element containing the block, which is often the parent element width of the block element. Of these 7 attributes, only the width, and the left and right margins, the 3 properties can be set to auto.
1. If you set a value in Width,margin-left or Margin-right to auto, and the remaining two properties are specified as a specific value, the property set to auto determines the desired length so that the width of the element box is equal to that of the parent element. The sum of the 7 attributes must be equal to 400px, no padding and borders are set, the right margin and width are set to 100, and the left margin is set to auto. Then the width of the left margin will be 200;
2, if these 3 properties are set to a value other than auto, the margin-right is always forced to auto, if the width and margin are 100px, the user agent will reset the right margin to auto, the actual width of the right margin is set according to the auto value.
3. If the two margins are set to auto, they are set to equal lengths, and if width and one margin are auto, the margin set to auto will be reduced to 0;width to the desired value.
4, if all is auto, then the margin is 0,width will be as wide as possible
The border cannot be a percentage.
Replace element
All rules for non-replacement elements also apply to replacement elements, with one exception, and if width is auto, the width of the element is the intrinsic width of the content.
Vertical formatting
In CSS, you can set the display height for any block-level element.
If the height is less than the height required to display the content, the browser adds a scroll bar to the element.
Vertical properties
Vertical formatting also has 7 related attributes, Margin-top, Border-top, padding-top, height, padding-bottom, Border-bottom, and Margin-bottom.
Only 3 of these 7 properties can be set to auto, the height of the element content, and the top and bottom margins. Both the top and bottom padding and border must be set to a specific value.
If the upper and lower margins of a block element are auto, it is automatically calculated as 0.
In-line elements
css-Basic Visual formatting