Home  >  Article  >  Web Front-end  >  Detailed introduction to absolute positioning and relative positioning in CSS

Detailed introduction to absolute positioning and relative positioning in CSS

高洛峰
高洛峰Original
2017-03-27 09:13:171993browse

The hierarchical relationship is:

Rendering:

Detailed introduction to absolute positioning and relative positioning in CSS

is after changing the reference object (orange box) Effect
The hierarchical relationship is:

Rendering:

Detailed introduction to absolute positioning and relative positioning in CSS

The reference object is the top element .
The hierarchical relationship is:

Rendering:

Detailed introduction to absolute positioning and relative positioning in CSS

The situation of using only the margin attribute to layout absolutely positioned elements
In this case, the values ​​of margin-bottom and margin-right no longer affect the element in the document flow because the element has been separated from the document flow. In addition, regardless of whether its ancestor element is positioned or not, the reference object is offset from its original position in the document flow.
In Figure 9, use the margin attribute to layout relatively positioned elements.
The hierarchical relationship is:

Rendering:

Detailed introduction to absolute positioning and relative positioning in CSS

##In the case of IE6, there are no sibling nodes in front of box2 , then the value of margin-left will have double margins, see Figure 10.

The hierarchical relationship is:

Rendering:

Detailed introduction to absolute positioning and relative positioning in CSS

The above is the detailed content of Detailed introduction to absolute positioning and relative positioning in CSS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn