Rereading last months entry, it occurred to me that some people could take my sharp attitude towards CSS the wrong way. It's clear that CSS is much better then HTML 4. Many sites are using CSS2, it sounds foolish to be so late to the event. But for any web designer who positions themselves to provide interactive and graphic services, the technological side has to be solid. Frankly CSS1 was not. CSS2, a few years ago, was not.
There still remains a number of tricky hacks. It's a waste. It's a waste of man hours on details that only keep a few hackers in business. I promised a few tips on positioning. Here's a thing. The CSS2 spec states:
"In the absolute positioning model, a box is explicitly offset with respect to its containing block. It is removed from the normal flow entirely (it has no impact on later siblings)." W3
I took this to mean if you had two nested DIVs and the first one position set to normal flow and the second set to absolute positioning, then the second DIV would position based on the location of its parent. This is not the case. Static, Float, and Relative positioning models all behave as expressed in the CSS2 specification. The absolute positioned DIV will offset from the BODY element, or the top of the page, unless it's a child of another absolute positioned box OR a relative positioned box. A problem remains, both are pulled from the normal flow and positioned z vertically above any static or float boxes. The combination of these exceptions in the rules for positioning make layouts still tricky. The fix is to nest the absolute box in a relative positioned box and to use the clear: both property in any subsequent normal boxes.
If you choose a simple two column or three column layout from some of the examples out there, you'll be fine. However, if you try to implement a layout with several positioning schemes you'll run into these problems.
I would like the CSS2 spec to have a property in the absolute and relative positioning rules to suppress this floating characteristic. This would make the rule effective in a combinations of layouts. I know that coders gain a lot of attention when they can solve basic problems (like the box model hack by Jeffrey Veen). Maybe I'm just jealous, because this problem is not a bug of addition. I have a problem with hack divs. What is CSS supposed to be about? Separating content from structure? Well if a coder has to create a hack div to get a layout to do some spatial arrangement, then this structure is separated from common sense.
//EDIT fixed an error in my stated fix above.
Post a Comment
<< Home
0 Comments: