CSS Negative margins for positioning.
Posted
by Kyle Sevenoaks
on Stack Overflow
See other posts from Stack Overflow
or by Kyle Sevenoaks
Published on 2010-04-13T13:12:42Z
Indexed on
2010/04/13
13:22 UTC
Read the original article
Hit count: 341
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 too.
For example I have a checkout page with three divs on top of each other
<div class="A">
header
</div>
<div class="B">
content
</div>
<div class="C">
footer
</div>
(A, B and C), which are meant to sit on top of each other, to appear attached. I did this using:
.B
{
margin-top: -20px;
}
On div B, to meet the bottom of div A.
Is this good practice or shall I re-code using top
and left
?
© Stack Overflow or respective owner