Tuesday, April 8, 2008

Relatively Absolute Positioning

So I came across a bug in our layout that was driving me nuts. I was trying to lay a div ontop of another div, so I was using relative positioning. Seems reasonable. However, when using relative positioning, it leaves a white gap where the div used to be.

I finally came across this nice little CSS tutorial about positioning and I learned something new. Apparently, you can have an outer div with relative positioning, and have the inner div absolutely positioned inside: a relatively absolute positioned div! Amazing! Since absolute positioning removes the div from the flow completely, no white gap is left behind!

One problem in IE though (as usual), is that anything with relative positioning inside the absolute div is covered up (doesn't show). FF is perfectly fine though (go figure...). I got around this problem by using margins instead.

You may probably know this, but for those that didn't... enjoy!


W

No comments: