Android Webkit: Absolutely positioned elements don't respect z-index Android Webkit: Absolutely positioned elements don't respect z-index android android

Android Webkit: Absolutely positioned elements don't respect z-index


This problem is probably related to controls and their being special for the browser. While looking at your problem (in chromium) I found a related problem that when you press the tab key you will still be able to focus the input elements. You probably don't want this either (regardless of bleedthrough). The solution is surprisingly simple, you write your script to add the disabled attribute to all input/button/etc. elements that are overlayed. A disabled input will not be able to receive focus (by keyboard or otherwise), and clicking it should be impossible.

As this also disables silly keyboard circumnavigation it is not even a workaround, but a better design that also works with keyboard based navigation as expected.


To answer the question properly it's important to read the bug page. The problem is not about visibility of the input below, but its "clickability".

I can't test it, but these are possible workarounds:

0 Forget absolute positioning and just put two divs there and toggle visibility.

If this doesn't satisfy You...

1 try setting CSS position to absolute or relative for all a and input tags (Yup, this might force You to rewrite CSS to keep the layout, but isn't it worth it?)

2 make a <a>-tag container:

 <div style="z-index:100 etc."><a style="width: 100%; height:100%; z-index:101">     stuff here </a></div>

This will need some more CSS to make the content look ok. But I expect something like this would solve the problem.

if 1 and 2 aren't helping try them both at once ;)

3 if it still happens You might want to check in details what happens when You click. Bind click and mousedown events to: link on top, container on top, input in the bottom and log them. If You get any of those events for the top link You can try and stop the bubbling at some moment or prevent the event on the input in the bottom.

This would be difficult, but I can help a bit. jQuery would be quite necessary.


Past fixes for this issue for IE include, but are probably not limited to the following list. These may help solve the problem in Android for you.

  1. Put an iframe behind the absolute content. The iframe may obscure those elements for you

  2. When you display your absolute content, hide all of the problem elements with JavaScript

  3. Define the div's in the opposite order

Point number 1 is deemed the most reliable fix for IE, but may not be the nicest fix for you.