My z-index property is not getting set [closed]

2019-01-15 21:40发布

I have a site with a log-in and a contact module, which is sliding out from the top-left side of the page. I have only one problem: the log-in module is working fine, but the contact module is going underneath the text, rather than above it. I set z-index: 999999; but, it still isn't working. I'm using position: fixed;

标签: css z-index
2条回答
老娘就宠你
2楼-- · 2019-01-15 22:23

if you go up the dom tree until .art-block and set z-index there it fixes the problem. Confirmed in firebug. Not to the whole .art-block class but you'll need to add a new class there, or id, or inline -- to that specific .art-block.

查看更多
一纸荒年 Trace。
3楼-- · 2019-01-15 22:31

Moving #iUngicontactForm from the table to the body tag will fix it. The problem is that the z-index of an element is inherited from it's parent and it only applies to sibling elements. And as you're using fixed positioning, it's a quick fix.

So instead of something like this:

<body>
   <table>
     <tr><td>some content..</td></tr>
     <tr><td><div id="iUngicontactForm"></div></td></tr>
    </table>
</body>

do this:

<body>
   <div id="iUngicontactForm"></div>
   <table>
     <tr><td>some content..</td></tr>
    </table>
</body>
查看更多
登录 后发表回答