PDA

View Full Version : CSS Positioning ?


hairynugs6382
09-06-2002, 11:11 PM
What is the diference between

position:relative;
position:absolute;
position:fixed;


?????

please explain 4 me!

Thank you!

Vladdy
09-06-2002, 11:23 PM
RTFM (http://www.w3.org/TR/REC-CSS2/visuren.html#positioning-scheme) ;)

Roy Sinclair
09-06-2002, 11:31 PM
position: absolute;

This is used to make a "layer" which can be repositioned anywhere on the web page (or even off the web page when you set negative x and/or y pixel locations). Any elements nested inside the tag with the absolute position are part of the layer and will move with it. The layer itself though isn't part of whatever tags it may have been nested within.

position: relative;

This works like position: absolute with the exceptions that it is a part of whatever tag it's nested within and the x/y positions are relative to the containing tag instead of to the window as a whole.

position: fixed;

This one is like absolute except the x/y position is set vs the viewing window and not the page. The difference is that an absolutely positioned element will scroll with the page while a fixed position element stays fixed at the same place in the browser window.

Simplified, there's more but this is the basics.

Edit: Oh yeah, IE doesn't support position: fixed; so you can't count on it yet.