Is there anything wrong with positioning all elements relatively?

后端 未结 4 1073
天命终不由人
天命终不由人 2020-12-16 06:35

Often I find myself attaching a class to an element just to give it position: relative; so that I can position it\'s children using position: absolute;

4条回答
  •  自闭症患者
    2020-12-16 07:16

    If you apply position: relative to all elements in the page, you won't be able to use position: absolute efficiently, because you can't position an element to the grandparent and you will probably break in a unpredictable way external plugins/modules that rely on position: absolute.

    You may encounter problems with z-index (for example in dropdowns menu), and you'll end up overwriting this behaviour with position: static and position: absolute.

提交回复
热议问题