Results 1 to 2 of 2
Nov 29, 2003, 11:00 #1
- Join Date
- Aug 2003
- Twighlight Zone
- 0 Post(s)
- 0 Thread(s)
Is Absolute Positioning Lazy CSS?
I was wondering - often, the only successful complicated XHTML layout I can seem to manage forces me to use absolute positioning in my stylesheets. Is this bad? Is this lazy? Is there "always a solution" in relative positioning? Or is it okay? I'm sure this is something people will have mixed opinions on, but I am really curious as to what everyone thinks. Somehow I feel like maybe I'm not a <em>true</em> XHTML/CSS designer if I use absolute pixel-perfect positioning.
Rockin' in the free world...
brilliant nonsensical ramblings
Nov 29, 2003, 11:12 #2
- Join Date
- Jan 2003
- Hampshire UK
- 183 Post(s)
- 6 Thread(s)
Absolute positioning is perfectly ok where necessary. Sometimes the only way to achieve a certain layout will be with a mixture of positioning.
Beginners usually go wrong when they absolutely place everything and then wonder why it's so hard to keep track of everything and why it's not fluid. As absolute elements are removed from the flow the only way to follow them is by using some more positioning etc
If you can keep everything in the flow that needs to be, it is a lot easier to control and you can still place the elements in relation to each other using margins if necessary. However, most pages will need a mixture of positioning to achieve their layouts.
It's important to remember that absolutely placed elements can be placed in relation to their parents (if parent has a position defined) and then the absolutely placed element is tied to the parent and will move if the parent also moves.
On the other hand position:relative is often misused (or misunderstood) and I find very few cases where it's actually needed. (Other than to set a stacking context for an element or set a positioning context where no co-ordinates are needed.)
The problem arises in that when an element is moved relatively it is only moved in relation to itself and the space it previously occupied is preserved.
Absolute positioning is just another tool in the box and used in the right place is perfectly acceptable.