'is there any problem if I give Z-index =99999999999

I'm building a widget. So it needs to appear on top of other pages. When I add the widget onto other websites,

I see that sometimes, other widgets come on top of my widget or some elements on the page come on top of it.

There are 2 solutions, I am thinking of.

  1. Give a very big number to the z-index value like 99999999999. Is this a good approach?

  2. Identify the biggest z-index number. And then adding on top of it? Which is a better approach?



Solution 1:[1]

You just can't give any long number for z-index. The range of the z-index is ±2147483647. (For 32 bit operating systems)

A very big number for CSS is perhaps a lazy way to ensure that the element is always on top. It can lead to problems down the road when multiple elements need to be on top.

My recommendation would be to check the context and then apply the z-index value and I would go for underlying layer + 1 option(Option 2 in your OP).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tushar