Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimum and maximum value of z-index?

Tags:

html

css

z-index

I have a div in my HTML page. I am showing this div based on some condition, but the div is displaying behind the HTML element where I pointed the mouse cursor.

I have tried all values for z-index from 0 - 999999. Can anyone tell me why this is happening?

Is there any minimum or maximum value of Z-INDEX property of CSS?

.divClass {       position: absolute;        left: 25px;        top: 25px;        width: 320px;       height: 300px;        z-index: 1000;   }
<table cellspacing="0" cellpadding="0" width="100%">    <tr>      <td>        <asp:HyperLink ID="lnkProgram" runat="server"></asp:HyperLink>      </td>    </tr>    <tr>       <td>           <div class="divClass">             Some Data           </div>       </td>    </tr>   </table>

I am showing and hiding the div with .divClass onclick via the <asp:hyperlink> using jQuery.

like image 340
Sachin Gaur Avatar asked Jan 29 '09 09:01

Sachin Gaur


People also ask

What does Z Index 9999 mean?

CSS z-index property always work with absolute as well as relative positioning value. CSS z-index possible value 0, positive (1 to 9999) and negative (-1 to -9999) value to set an element. Properties. Value.

What Z index value is for?

Definition and Usage. The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element with a lower stack order.

What does Z Index 1000 mean?

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.

What Z index means?

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 ).


2 Answers

http://www.w3.org/TR/CSS21/visuren.html#z-index

'z-index'

Value: auto | <integer> | inherit

http://www.w3.org/TR/CSS21/syndata.html#numbers

Some value types may have integer values (denoted by <integer>) or real number values (denoted by <number>). Real numbers and integers are specified in decimal notation only. An <integer> consists of one or more digits "0" to "9". A <number> can either be an <integer>, or it can be zero or more digits followed by a dot (.) followed by one or more digits. Both integers and real numbers may be preceded by a "-" or "+" to indicate the sign. -0 is equivalent to 0 and is not a negative number.

Note that many properties that allow an integer or real number as a value actually restrict the value to some range, often to a non-negative value.

So basically there are no limitations for z-index value in the CSS standard, but I guess most browsers limit it to signed 32-bit values (−2147483648 to +2147483647) in practice (64 would be a little off the top, and it doesn't make sense to use anything less than 32 bits these days)

like image 153
Tamas Czinege Avatar answered Oct 28 '22 23:10

Tamas Czinege


My tests show that z-index: 2147483647 is the maximum value, tested on FF 3.0.1 for OS X. I discovered a integer overflow bug: if you type z-index: 2147483648 (which is 2147483647 + 1) the element just goes behind all other elements. At least the browser doesn't crash.

And the lesson to learn is that you should beware of entering too large values for the z-index property because they wrap around.

like image 24
Ran Avatar answered Oct 29 '22 01:10

Ran