CSS Negative Positioning Fields

Can negative fields be used for positioning? I have a lot on my current site and feel that this is not such a stable way of positioning things. I usually suggest using them too.

For example, I have a checkout page with three divs on each other

<div class="A"> header </div> <div class="B"> content </div> <div class="C"> footer </div> 

(A, B and C) that are designed to sit on top of each other so that they are attached. I did this using:

 .B { margin-top: -20px; } 

On div B to meet the bottom of div A.

Is this good practice or will I recode using top and left ?

+4
source share
2 answers

If your divs have some margin among themselves, you may not reset your margins and indents (see: http://meyerweb.com/eric/tools/css/reset/ ).

Generally speaking, it’s nice to use negative fields, anyway, if you are forced to set them almost everywhere, you should probably reorganize your css, because the result may be slightly different from different browsers, and this can lead to a big headache :).

+5
source

Negative fields are known to cause problems in IE7 and below with content disabled. And, as the alias suggests, this may also indicate a problem with the rest of the design. But I think it is erroneous to say that negative fields are "poor development" in all cases. But, as always, a test test test.

0
source

Source: https://habr.com/ru/post/1306802/


All Articles