javascript - How to always fix a div in a certain position; no matter how the screen and resolution change; the div position will always remain the same
世界只因有你2017-06-24 09:43:50
0
4
824
How to fix a p in a certain position; no matter how the screen and resolution change; the position of p will always remain unchanged
position: static | relative | absolute | fixed | static: Objects follow regular flow. At this time, the 4 positioning offset attributes will not be applied. relative: The object follows the regular flow, and it will not affect any elements in the regular flow when it is offset with reference to its position in the regular flow through the four positioning offset attributes of top, right, bottom, and left. absolute: The object breaks away from the regular flow. At this time, the offset attribute refers to the positioned ancestor element closest to itself. If there is no positioned ancestor element, it goes back to the body element. The box's offset position does not affect any elements in the regular flow, and its margins are not collapsed with any other margins. fixed: Same as absolute, but the offset positioning is based on the window. When scroll bars appear, objects do not scroll.
Add position to p: fixed
position: static | relative | absolute | fixed |
static:
Objects follow regular flow. At this time, the 4 positioning offset attributes will not be applied.
relative:
The object follows the regular flow, and it will not affect any elements in the regular flow when it is offset with reference to its position in the regular flow through the four positioning offset attributes of top, right, bottom, and left.
absolute:
The object breaks away from the regular flow. At this time, the offset attribute refers to the positioned ancestor element closest to itself. If there is no positioned ancestor element, it goes back to the body element. The box's offset position does not affect any elements in the regular flow, and its margins are not collapsed with any other margins.
fixed:
Same as absolute, but the offset positioning is based on the window. When scroll bars appear, objects do not scroll.
Give me a fixed left, top, etc.
The p position needs to remain unchanged
The percentage will definitely not work,
Recommended units:
px
rem
Theoretically
position
is required:cannot be
statuc