View Full Version : Absolute positioning with CSS


BahamaLouie
01-12-2006, 05:36 PM
Hi,
How does absolute positioning work with css? Does the it move all around in different browsers or does it stay where it's supposed to? I'm asking this question because I've had really bad luck with trying to do this with pictures in FrontPage.
Thanks,
Louis
www.bahamalouie.com

djou
01-12-2006, 07:51 PM
I'm not going to make a rant about FrontPage here...

Concerning absolute positioning, it does what its name says: it places an element on the page exactly where you tell it to be. If you write position:absolute;top:30px;left:20px, then it will be 30 pixels from the top of the browser window and 20 pixels from the left.

tail451
01-12-2006, 08:43 PM
Whenever I position my div's, I like it to be the same in every browser/resolution. So that's impossible right? No. When you're positioning a div layer you probably align it like this:
<div id="1" style="position:absolute; left:40px; top:50px;">Stuff in layer</div>

But that will only look good in the resolution/browser you're using. So if you want your page to be cross-browser and cross-resolution compatible, you have to align your div's with the margin-left code:
<div id="1" style="position:absolute; left:50%; margin-left:50px; top:50px;">Stuff in layer</div>

When you use margin-left, you CAN use negative integers. Also when you use this, make sure you make left: 50%.