3 ms·
I find similar issues with z-index in CSS. Early in a project, people stick to some heuristic, like using small z-index values like 0, 1, 2, 3... etc. But this
by swagasaurus-rex 6y ago
I find similar issues with z-index in CSS.
Early in a project, people stick to some heuristic, like using small z-index values like 0, 1, 2, 3... etc. But this has drawbacks because you can't add new z-index items in between without also shifting everything with a higher z-index
Using z-index values with a gap is a better bet. 0, 10, 20, 30, etc. Of course, you are limited to only a few items in between the original. You've also lost an expectation of ordering in the values.
Larger gaps make more sense, as long as you don't exceed the size of signed integers ±2147483647.
The author of the post mentions how floating point has a similar problem in the amount of floating point precision you can wring out before you end up with rounding errors.
The true crux of the problem is one of items related to one another, in other words it's a graph problem. I want these items to show up underneath these other items.
- recursive 6y agoIf I need to fit something between z-index 2 and 3, I'd just put it at 2, and subsequent to all the other z-index 2 elements.
- rubatuga 6y agoThen you have projects like bootstrap using z vals of 3000 etc.
- names_are_hard 6y agoThen someone gets fed up because they just want their item to be on top, dammit, so they can finish their jira task and move on. So they just type 9999 because that ought to beat all those other pesky z-indexes...
- kflzufkrbzi 6y agoWrap whatever they provide with position: relative, z-index: 1 and their 3000 index will not go over your 2 index.
- earthboundkid 6y agoThe IAB has standard z-indexes in the millions: https://cravencode.com/post/essentials/iab-z-index-guidelines/ https://cravencode.com/post/essentials/iab-z-index-guideline...