CSS Negative margins for positioning

后端 未结 2 1842
慢半拍i
慢半拍i 2021-01-13 13:34

Is it ok to use negative margins for positioning? I have a lot in my current site and feel like it\'s not such a stable way to position things. I usually suggest to use them

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-13 13:40

    If your divs have some margin between each other probably you didn't reset your margins and padding (see: http://meyerweb.com/eric/tools/css/reset/).

    Generally speaking is not a bad thing to use negative margins, anyway if you are forced to set them almost everywhere probably you should refactor your css, because the result can be slightly different among the various browsers and this could lead to a big headache :) .

提交回复
热议问题