Monday, June 29, 2009

CSS Z-Index

One CSS rule (as I have come to learn them to be called) that is a pain in the ass is the Z-Index. Why? Because it works the way you want it about 60% of the time every time. Besides the obvious movie reference (Anchorman for anyone not familiar), it's just a confusing rule. Basically, it allows the programmer to stack elements on the Z-Index, as the rule name so aptly describes. So here are some basic guides to Z-Index.
  1. You should try any other possible method to get the stacking order you wish before using Z-Index
  2. If Z-Index is the only way to go, every stacking element must have the CSS property 'position' set to 'absolute' or 'relative'
  3. The lower the Z-Index, the lower in the stack it goes (less visible).
That's about it. Again, I hate Z-Index, but I do find that sometimes you have to use it...

No comments: