cm0002@libretechni.ca to Web Development@programming.devEnglish · 2 days agoThe Value of z-index | CSS-Trickscss-tricks.comexternal-linkmessage-square4linkfedilinkarrow-up116arrow-down10
arrow-up116arrow-down1external-linkThe Value of z-index | CSS-Trickscss-tricks.comcm0002@libretechni.ca to Web Development@programming.devEnglish · 2 days agomessage-square4linkfedilink
minus-squaredanAlinkfedilinkarrow-up8·2 days agoI like the idea of using CSS variables for consistency. Many years ago, before CSS variables were a thing, I did a very similar thing using a LESS function: $zindices: hero-mobile, nav-bar, hero, nav-contents; @function zindex($layer) { @return index($zindices, $layer); } Which would be used like: z-index: zindex('hero'); The z-index value is just that string’s position in the list.
I like the idea of using CSS variables for consistency.
Many years ago, before CSS variables were a thing, I did a very similar thing using a LESS function:
$zindices: hero-mobile, nav-bar, hero, nav-contents; @function zindex($layer) { @return index($zindices, $layer); }Which would be used like:
z-index: zindex('hero');The z-index value is just that string’s position in the list.