in Chrome when i set z-index to 2147483647 it changes to 1e+06.. what is the maximum possible value for chrome?
The maximum range is ±2147483647. In CSS code bases, you'll often see z-index values of 999, 9999 or 99999.
z-index defines which positioned element appears on top (Sort of like layers). So z-index: 1000 would appear on top of a z-index 999 . Doing z-index: 1001 is an an attempt to appear "on top" of a item with z-index: 1000.
The default z-index value of all the elements on a web page is auto, which corresponds to 0 where no z-index is assigned. An element with z-index: -1 will be displayed behind all other elements on the page, assuming they are given no z-index values.
Z Index ( z-index ) is a CSS property that defines the order of overlapping HTML elements. Elements with a higher index will be placed on top of elements with a lower index. Note: Z index only works on positioned elements ( position:absolute , position:relative , or position:fixed ).
.css('z-index', '99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999').css('z-index')
becomes 1e+308
. If you add another digit after it becomes "inf".
Being a 32-bit browser, you found the highest value.
2147483648 = 2^31
It is 2147483647 (0x7fffffff).
According to the source code of WebKit, the "zIndex" has been an "int" value since the first commit: https://chromium.googlesource.com/chromium/src/+/d869b93fe74f4d6cb2dd6f6c3e9bf9daee39ba19/third_party/WebKit/WebCore/khtml/rendering/render_style.h#828 .
And tests on Chrome 35 (32-bit), 45 (64-bit), 74 (64-bit) (for Windows) confirm it.
I also tested Firefox 66 and max of zIndex is also 2147483647 there.
Notes:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With