Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Safari Z-index not working

Tags:

html

css

ios

I have a dropdown menu in HTML but it's hidden by some other page content on iOS. The dropdown appears perfectly on Android and PC but refuses to appear on iOS Safari browser (Tested on iOS 9 and 10).

I have specified a higher z-index for the dropdown and a lower one for the page content. I have also tried:

-webkit-transform: translate3d(0,0,1px);
transform: translate3d(0,0,1px);

with no luck.

Here is my CSS:

Dropdown

.dropdown-content2 {
    display: none;
    position: fixed;
    left: 10%;
    background-color: #EFEFEF;
    padding: 20px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 99;
    font-size: 13px;
    width: 50%;
    height: 300px;
    overflow-y: auto;        
    -webkit-transform: translate3d(0,0,1px);
    transform: translate3d(0,0,1px);  
}

Page Content

.newmain{
  margin-left:0px;
  margin-top: 130px;
  padding: 20px;
  z-index: 90;
}
like image 846
grape657 Avatar asked Jun 24 '18 19:06

grape657


People also ask

Why Z-index is not working?

z-index only works on positioned elements (relative, absolute, fixed, sticky) so if you set a z-index on an element with a static position, it won't work.

Does Safari support Z-index?

Bookmark this question. Show activity on this post. The Z-index isn't rendering properly on Safari - but it is working fine on Chrome and Firefox.

Why Z-index is not working with div?

The root element forms the root stacking context. Other stacking contexts are generated by any positioned element (including relatively positioned elements) having a computed value of 'z-index' other than 'auto'. Stacking contexts are not necessarily related to containing blocks.

Does position absolute affect Z-index?

Note: z-index only works on positioned elements (position: absolute, position: relative, position: fixed, or position: sticky) and flex items (elements that are direct children of display:flex elements).


3 Answers

It was not a Z-index issue. Turns out the parent element of the dropdown was set to overflow: hidden. Setting it to Overflow: visible solved it. Thanks.

like image 130
grape657 Avatar answered Oct 21 '22 05:10

grape657


In my case, I found the container of the element should be on the top.

I saw this: -webkit-overflow-scrolling: touch;

Then I replace it by -webkit-overflow-scrolling: auto !important;

That solved my bug.

I hope this help you!

like image 29
Duc Chi Avatar answered Oct 21 '22 04:10

Duc Chi


-webkit-overflow-scrolling: auto !important;

work for me.

like image 26
user2943576 Avatar answered Oct 21 '22 04:10

user2943576