Difference between static and relative positioning

后端 未结 8 1291
野性不改
野性不改 2020-11-27 11:09

In CSS, what is the difference between static (default) positioning and relative positioning?

相关标签:
8条回答
  • 2020-11-27 11:45

    Relative position is relative to the normal flow. The relative position of that element (with offsets) is relative to the position where that element would have been normally if not moved.

    0 讨论(0)
  • 2020-11-27 11:53

    You can see a simple overview here: W3School

    Also, if I recall correctly, when declaring an element relative, it will by default stay in the same place as it otherwise should, but you gain the ability to absolutely position elements inside it relatively to this element, which I've found very useful in the past.

    0 讨论(0)
提交回复
热议问题