Home  >  Q&A  >  body text

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

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

世界只因有你世界只因有你2674 days ago778

reply all(4)I'll reply

  • 三叔

    三叔2017-06-24 09:45:50

    Add position to p: fixed

    reply
    0
  • 怪我咯

    怪我咯2017-06-24 09:45:50

    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.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-06-24 09:45:50

    Give me a fixed left, top, etc.

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-06-24 09:45:50

    The p position needs to remain unchanged

    The percentage will definitely not work,

    Recommended units:

    • px

    • rem

    Theoretically position is required:

    • cannot be statuc

    reply
    0
  • Cancelreply