views:

277

answers:

2

I've got a basic layout where the body div is set to a specific width. And with margins left and right are set to auto. Resulting in the div being centered.

Now, when it now comes to positioning all sub elements within this div, is it best to use absolute positioning or fixed coordinates? These sub elements are basically columns of text, some images and a few headings. I've found that floating all of them to the left makes them stack behind each other. Which is basically what I want. But would it be better to specify the coordinates? I ran into a small common margin bug with IE you see. And I know absolute positioning would fix it. But would that be a dirty fix?

I mean, the layout itself is liquid in some sense. But the body div has its width. So the sub elements won't move around regardless of resolution.

+2  A: 

Note: the margin bug in IE can also be "fixed" by wrapping the div with a margin in a div without a margin, and floating that outer div.

As to absolute vs. float: I suggest you have a look at this page, which seems like a good summary, and ask yourself if any of the cons raise a red flag for you.

I personally would use absolute positioning if all the div's contents are static, and float if some are dynamic. But that's a subjective answer.

Arkaaito
Ok, so I wasn't thinking way off then huh? :) I think I'll stick with absolute positioning this time around. :)
Kenny Bones
A: 

I don't see a problem with using absolute positioning. One possible downside would be that your style sheet would be a little harder to maintain, because you would have widths and positions specified. If you had to change the width of any of your columns in the future, you would have to update the pixel value in 2 places. IMO using float and margin would be easier to modify in the future.

wsanville