You can't make assumptions like this; z-index depends on stacking contexts.