0

I have had so much problems with position: relative (especially regarding any divs that come after it) that I'm starting to think an overall rule is to keep with static and use margin to move things around when at all possible and use relative when you need it for negative placements, etc.

I was working on a messed up page today where the divs were overlapping and covering each other. I switched all the relatively position divs to static and reimplemented the shifts using margins and now it looks great.

Am I off base?

5
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by metalix
0

Yes, way off base.

Position:absolute is dreadful, while position:relative often SOLVES problems with other things.

If divs are physically overlapping, that means you have some strange code elsewhere that is the real problem.

0

I know it's not good, but I actually like to embed PHP in my CSS. I have problems with position:relative. Mainly, I can't get things to overlap as well as position:absolute.

0

Yes, way off base.

Position:absolute is dreadful, while position:relative often SOLVES problems with other things.

If divs are physically overlapping, that means you have some strange code elsewhere that is the real problem.

Who said anything about absolute?

Once again, just switching to position:static and changing the offsets to margin-left and margin-top instead of left and top instantly fixed all the problems.

Before, there was weird overlap of divs all over the place.

After, it laid out just as you would expect.

0

I use relative position almost all the time...and I have absolute position..
You can't build a site only with absolute position

0

Who said anything about absolute?

No-one.
it was a comparison of how one way of positioning is well know for causing problems, while another way is well known for solving problems. But you thought that the one that often solves things was a source of problems. That's all.

And of course there are lots of different ways of solving layout problems.

0

position:absolute is only really needed when you want to have a box that follows down the screen or a div on a div to add depth etc.
position:relative can tend to confuse things alot if the code gets messed up a little.
and generally any layout can be made with simple tables anyway.

and theres nothing wrong with embeding php in css or vice-versa.
if it works, who can complain?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.