You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

z-index失效问题:网站子菜单被footer遮挡求解决方案

Hey Bart, let's get that submenu showing above your footer without breaking your backend tables—let's focus on fixing the z-index issue properly.

First, let's diagnose why your current setup isn't working: z-index only affects elements that have a non-static position (so relative, absolute, fixed, or sticky). If your submenu is using the default position: static, the z-index values you set on parent elements won't help it stack above the footer, even if #main has a higher z-index than footer. The footer comes after #main in your HTML, so static elements in #main will get covered by the footer.

Here's how to fix it step by step:

  • Give your submenu a non-static position and explicit z-index:
    Target your submenu element (e.g., .webcams-submenu) and add these styles:

    .webcams-submenu {
      position: absolute; /* Absolute works best for dropdown positioning */
      z-index: 101; /* Set this higher than your header's z-index (100) to ensure it stays above all content */
    }
    

    This ensures the submenu creates its own stacking context and sits above everything else, including the footer.

  • Set a relative position on the submenu's parent:
    The main menu item that triggers the hover needs position: relative so the absolute-positioned submenu anchors correctly to it:

    .menu-item-with-submenu {
      position: relative;
    }
    
  • Confirm your footer's stacking context:
    Since your footer is inside #wrapper with z-index: 1, and #main has z-index: 50, the footer is already in a lower stacking context than #main. As long as your submenu has a non-static position and a z-index higher than any other elements, it will sit above the footer without needing to modify overflow on #main.

This approach avoids the overflow: visible issue that broke your backend tables, since we're fixing the stacking order directly instead of altering how #main clips its content.

内容的提问来源于stack exchange,提问作者Bart F. W.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:11:09