The positioning of position in css is: 1. static; 2. fixed; 3. relative; 4. absolute. Static is equivalent to no positioning, and relative generates relatively positioned elements.
There are four values for position in css, namely static, fixed, relative, and absolute.
(Learning video tutorial: css video tutorial)
Detailed introduction:
static: equivalent to no positioning, element will appear in the normal document flow.
fixed: The element box behaves like absolute, but fixed is positioned relative to the view window itself, that is, the browser window. Therefore, when the element with this positioning is scrolled down on the page, its position will not change.
relative: Generate a relatively positioned element, which is positioned relative to the position of the element itself, and the space it originally occupied will still be retained.
absolute: Generate an absolutely positioned element and position it relative to the first positioned ancestor element other than static positioning. Since static positioning is equivalent to no positioning, absolute positioning is actually positioned relative to the first positioned ancestor element. If all ancestor elements are not positioned, it will be positioned relative to the initial containing block or canvas, usually the body element.
Related recommendations: CSS tutorial
The above is the detailed content of What are the positioning positions in css?. For more information, please follow other related articles on the PHP Chinese website!