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?

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.

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.

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.

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

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.

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.