About relative positioning and absolute positioning_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:24:44
Original
1406 people have browsed it

About relative positioning and absolute positioning

1. How to understand these two,
I feel like it is always unclear when others ask,
2. When should I use relative positioning? Positioning, when should you use absolute positioning?



Reply to discussion (solution)

About relative positioning and absolute positioning

1. How to understand these two?
I feel like it’s always unclear when people ask me.
2. When should I use relative positioning and when should I use absolute positioning?

Can you understand it this way?

Relative positioning is moving relative to the original position of the element.
After the element is moved, its original position will be retained and will not break away from the document flow.

Absolute positioning is absolute positioning relative to the parent, and after moving, the original position occupied by the element will not be retained and will be separated from the document flow.


About relative positioning and absolute positioning

1. How to understand these two,
I feel like it is always unclear when others ask,
2 .When should we use relative positioning and when should we use absolute positioning?

Can you understand it this way?

Relative positioning means moving the element relative to its original position.
After the element is moved , the position it originally occupied will be retained and will not break away from the document flow.

Absolute positioning is absolute positioning relative to the parent, and after moving, the original position occupied by the element will not be retained and will be separated from the document flow.

Absolute positioning is relative to the parent or the first one in the previous level that has a position (absolute or relative positioning is acceptable), and after moving, the original position occupied by the element will not be Retained, out of the document flow.

You seem to understand very well. Absolute positioning is separated from the document flow from the beginning and will not affect the layout of the main document flow.

You seem to understand very well. Absolute positioning is separated from the document flow from the beginning and will not affect the layout of the main document flow.

You seem to understand very well. Absolute positioning is separated from the document flow from the beginning and will not affect the layout of the main document flow.

Well, I couldn’t say it before.
And the box model, I know it has four attributes, padding (inner margin), margin (outer margin), border ( Border), content (content)
I can’t answer the other questions. ~

I have encountered this problem before. It is recommended not to use absolute layout, because the browser box model settings are somewhat different. If you use absolute layout, it will be implemented on different browsers. Dislocation is very likely to occur

Relative positioning: Positioning relative to my current position
Absolute positioning: I must be at this position

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template