position: absolute;
Friday, October 6, 2006When I sat down a few years ago to really learn CSS the most awesome thing I remember learning was that an absolutely positioned element positions itself relative to the nearest relative parent of that element . It could be the immediate parent or an ancestor, finally using the body element as a last resort. It was immediately clear how powerful that might be and I thought a compliment must be paid to the creators of the CSS standard for thinking of that. Best of all is that all browsers seem to get this rule right .
Absolutely positioned elements have been given a bad rap, I think. They seem to have been characterised as a low brow approach to standards based design, as in "I see you had to resort to absolutely positioned elements to get your layout right. Couldn't you work out how to do it any other way?". But the way I see it, because IE6 seems to have a lot of float problems [ 1 , 2 , 3 ], using absolutely positioned elements inside relatively positioned ones is a neat way to solve a whole bunch of layout issues [See Mezzoblue , Artistic Cuckoo or Stop Design].
Those articles are all quite old and I think position:absolute; may have been moved aside as the mainstream philosophy of CSS use seems to favour reliquishing control of page flow as opposed to gaining it, these days.
The only reason I bring it up is because I heard it mentioned at WE05 , and now again at WD06 . Andy Clarke made the statement that he thinks 2007 might be the year for the absolutely positioned element. A come back, not as a way of bypassing layout issues with crummy browsers, but in the sense of an aesthetic design descision. Could it be making a come back for the right reasons?
1 Comment
FWIW, my current project *requires* that I use a measure of absolute positioning... it felt odd at first, but the site looks good on it. Maybe 2007 *will* be the year!