Google Chrome not respecting z-index

后端 未结 6 1436
后悔当初
后悔当初 2020-12-31 01:06

As per the title, it seems only Chrome isn\'t playign along. Note that form fields cannot be clicked on which are on the left portion of the screen. This only occurs on some

相关标签:
6条回答
  • 2020-12-31 01:13

    Markt's answer (see first answer) is great and this is the "by definition" of the z-index property.
    Chrome's specific issue are usually related to the overflow property from the top container bottom. So, for the following:

    <div class="first-container">...</div>
    <div class="second-container">
        <div ...>
             <div class="fixed-div> some text</div>
        <... /div>
    </div>
    

    And styles:

    .first-container {
        position:relative;
        z-index: 100;
        width: 100%;
        height: 10%;
    }
    
    .second-container {
        position:relative;
        z-index: 1000;
        width: 100%;
        height: 90%;
        overflow: auto;
    }
    
    .fixed-div {
        position: fixed;
        z-index: 10000;
        height: 110%;
    }
    

    the following actually happens (Chrome only, firefox works as expected)
    The 'fixed-div' is behind the 'first-container', even though both 'fixed-div' and its container's ('second-container') z-index value is greater than 'first-container'.

    The reason for this is Chrome always enforce boundaries within a container that enforces overflow even though one of its successors might have a fixed position.
    I guess you can find a twisted logic for that... I can't - since the only reason for using fixed position is to enable 'on-top-of-everything' behavior.
    So bug it is...

    0 讨论(0)
  • 2020-12-31 01:13

    Without a link to look at, it's a bit tough to see what the problem might be.

    Do you have a z-index: -1; anywhere (a negative number is the key here, doesn't matter the number)? I have found in the past this renders the container void from being interacted with.

    Good luck!

    0 讨论(0)
  • 2020-12-31 01:16

    Google Chrome to 84.0.4147.135 (Official Build) (64-bit) 2020-02-22.

    Since my last update, CSS element z-index is broken in Chrome.

    Chrome added "z-index: 1;" to the BODY element.

    It now wrongly displays all z-index: ?; values in the BODY child elements.

    Setting the position, z-index of BODY does not solve the problem. Changing z-index values of child elements that were already correct does not help.

    I hope this issue will be fixed, it is only broken since I updated Chrome.

    Chrome 84.0.4147.135 bug on www.eatme.pro/music - screen smaller than 500 px - push play - appearing bottom bar #lblBottomBarLink with z-index 5 is displayed under menu with z-index 2

    (see image)

    image eatme.pro/music in Chrome 84.0.4147.135 with z-index 5 under z-index 2

    0 讨论(0)
  • 2020-12-31 01:17

    Usually when you have set the z-index property, but things aren't working as you might expect, it is related to the position attribute.

    In order for z-index to work properly, the element needs to be "positioned". This means that it must have the position attribute set to one of absolute, relative, or fixed.

    Note that your element will also be positioned relative to the first ancestor that is positioned if you use position: absolute and top, left, right, bottom, etc.

    0 讨论(0)
  • 2020-12-31 01:29

    I had a weird issue with zIndex on Chrome and I kept fiddling with the position attribute to see if anything worked. But, it didn't. Turns out, in my case, the issue was with the transform attribute. So, if you have a transform attribute in place, disable it and it should be fine. Other browsers work fine with stuff like that, but Chrome seems to play it differently.

    Hope this helped you.

    0 讨论(0)
  • 2020-12-31 01:30

    I know this is now resolved but posted solution didn't work for me. Here is what resolved my problem:

    <act:AutoCompleteExtender ID="ace" runat="server" OnClientShown="clientShown">
    </act:AutoCompleteExtender>
    
    <script language="javascript" type="text/javascript">
        function clientShown(ctl, args) {
            ctl._completionListElement.style.zIndex = 99999;
        }
    </script> 
    
    0 讨论(0)
提交回复
热议问题