In HTML, the percentage width and position of the box after relative, absolute, and fixed are prone to errors.
1. relative Positioning relative: as the name suggests, relative positioning is offset relative to its own position, for example:
Take the center of the box as the benchmark, which is the positive direction of each edge, for example:
Move 20px to the right: the code is left: 20px; or right:-20px;
Move 20px down: the code is top: 20px; or bottom:-20px;
2. absolute positioning: absolute
Based on its first ancestor-level box, the center direction of the ancestor-level is positive, for example:
3. fixed positioning fixed, which is independent of the body Tag, is based only on html of the webpage. Its Positioning method is similar to absolute positioning and is in the center direction as the positive direction.
The width percentage is only based on html.
Note: 1. If there is no parent-level positioning, absolute positioning of absolute is based on its first positioning ancestor by default.
2. Absolute positioning and relative positioning of the box, the width percentage is based on the first positioning ancestor; the default is based on the body