Positioning direction: Left | Right | Top | Bottomposition:static
static positioning. The default value is the document flow
Position:absolute
Absolute positioning features
- Element does not occupy the original position after using absolute positioning (off-label)
- The element uses absolute positioning, the position is from the browser
- Nested boxes, the parent box does not use positioning, the sub-box is absolutely positioned, the sub-box position is from the browser.
- Nested box, parent box using positioning, sub-box absolute positioning, sub-box position is from the parent element position
- After using absolute positioning for inline elements, convert to inline blocks. (not recommended, recommended for use with Display:inline-block;)
Position:relative
Relative positioning features
- Using relative positioning, the position starts from itself
- Still occupy the original position.
- = = Child Absolute Parent (relative positioning of parent element, absolutely positioning of child elements) = =
- Inline elements use relative positioning to not switch to inner block
Position:fixed
Fixed positioning features
- Fixed positioning, does not occupy the original position (off the mark)
- The position is set from the browser after using fixed positioning
- Elements are converted into inline blocks after using fixed positioning (not recommended, Display:inline-block are recommended;)
The Positioned box centers the display
- margin:0 Auto; You can only center the box of the standard flow.
- Centered box: Half 50% of the parent's box is left, and half of the box (margin-left: Negative value). )
.nav{ width:500px; height:60px; left:50%; margin-left:-480px}
Tags contain specifications
- Div can contain all the tags
- P tags cannot contain tags such as div h1
- H1 can contain labels such as P,div
- Inline elements contain inline elements as much as possible, and inline elements do not contain block elements
Bypass off-label flow
- Use standard flow as much as possible
- Standard flow can not solve the use of floating
- Floating can not solve the use of positioning
Positioning of CSS