Fixing Z-Index Issues with the Twenty Seventeen Drop-Down Menu
Content
If you've noticed your Twenty Seventeen theme's drop-down menu appearing behind page content when scrolling, you're not alone. This is a common issue caused by the way CSS stacking contexts work. This guide will explain why it happens and show you how to fix it with a simple CSS adjustment.
Understanding the Problem
The Twenty Seventeen theme uses z-index to ensure the menu overlaps page contents when scrolled. However, the main .site-content-contain block doesn't have a defined stacking context. When no stacking context is established, other positioned elements on the page with a z-index can potentially appear in front of the menu, breaking the intended design.
The Solution: Add a Z-Index
The most effective fix is to add a small piece of CSS to establish a new stacking context. This ensures the menu remains on top of other content as intended.
- Navigate to your WordPress dashboard.
- Go to Appearance > Customize.
- Click on Additional CSS.
- Paste the following CSS code into the text area:
.site-content-contain { z-index: 1; position: relative; } - Click Publish to save your changes.
This code assigns a z-index to the .site-content-contain element and ensures it is positioned, which creates a new stacking context. The menu, which has a higher z-index value, will now correctly appear on top of this container when scrolling.
Why This Works
By setting z-index: 1 and position: relative on the content container, you create a new local stacking context. The menu's z-index is now compared to other elements within this same context, allowing its higher value to take precedence and display correctly on top.
Alternative Method: Using a Child Theme
For a more permanent solution that won't be lost during theme updates, consider adding this CSS to a child theme's style.css file. This is a recommended best practice for any theme modifications.
By implementing this simple fix, you can ensure your Twenty Seventeen menu functions flawlessly and maintains a professional appearance on your site.
Related Support Threads Support
-
Twenty Seventeen drop-down menu z-indexhttps://wordpress.org/support/topic/twenty-seventeen-drop-down-menu-z-index/
-
Twentyseventeen: Menu and Big Image – no change on click … or?https://wordpress.org/support/topic/twentyseventeen-menu-and-big-image-no-change-on-click-or/
-
Automated ID’s on headings causes duplicate ID, breaks validationhttps://wordpress.org/support/topic/automated-ids-on-headings-causes-duplicate-id-breaks-validation/
-
TwentyFourteen scrolling problemhttps://wordpress.org/support/topic/twentyfourteen-scrolling-problem/
-
BuddyPress and header in Twenty Fourteenhttps://wordpress.org/support/topic/header-in-twentyfourteen/
-
FSE navigation (WP 5.9 beta): aria-labels are not sanitizedhttps://wordpress.org/support/topic/fse-navigation-wp-5-9-beta-aria-labels-are-not-sanitized/
-
WordPress latest 6.2 issues (themes, Gutenberg)https://wordpress.org/support/topic/wordpress-latest-6-2-issues-themes-gutenberg/
-
How can I target WordPress 3.8 new interface MP6 with CSS?https://wordpress.org/support/topic/how-can-i-target-wordpress-38-new-interface-mp6-with-css/
-
Dark themes in Gutenberghttps://wordpress.org/support/topic/dark-themes-in-gutenberg/
-
MP6 – how to make table scrollable horiziontally?https://wordpress.org/support/topic/mp6-how-to-make-table-scrollable-horiziontally/
-
6.1 RC1 – Hamburger menu is not working with Gutenberg 14.3.0https://wordpress.org/support/topic/6-1-rc1-hamburger-menu-is-not-working-with-gutenberg-14-3-0/
-
New Update Ignoring Remove Spacinghttps://wordpress.org/support/topic/new-update-ignoring-remove-spacing/
-
Gutenberg html outputhttps://wordpress.org/support/topic/gutenberg-html-output/
-
Update your plugins (Universal Border Box Sizing and Widget padding)https://wordpress.org/support/topic/update-your-plugins-universal-border-box-sizing-and-widget-padding/
-
The submenus dont work in mobile version Astra Themehttps://wordpress.org/support/topic/the-submenus-dont-work-in-mobile-version-astra-theme/
-
Hide title in Twenty Twenty homehttps://wordpress.org/support/topic/hide-title-in-twenty-twenty-home/
-
OMG What is the problem?? 2010??https://wordpress.org/support/topic/omg-what-is-the-problem-2010/
-
6.0-RC1-53342 Sticky header Twenty Twenty-Two Version: 1.2https://wordpress.org/support/topic/6-0-rc1-53342-sticky-header-twenty-twenty-two-version-1-2/
-
Checkbox checkmark is blue instead of whitehttps://wordpress.org/support/topic/checkbox-checkmark-is-blue-instead-of-white/
-
TinyMCE style dropdown shows "header" instead of "heading"https://wordpress.org/support/topic/tinymce-style-dropdown-shows-header-instead-of-heading/
-
UI issue in PluginSidebarMoreMenuItemhttps://wordpress.org/support/topic/ui-issue-in-pluginsidebarmoremenuitem/
-
Twenty Seventeen html validation errorshttps://wordpress.org/support/topic/twenty-seventeen-html-validation-errors/
-
Guteneberg page update – endless loophttps://wordpress.org/support/topic/guteneberg-page-update-endless-loop/
-
Gutenberg in when we click on publish blog to showing error : Updating failedhttps://wordpress.org/support/topic/gutenberg-in-when-we-click-on-publish-blog-to-showing-error-updating-failed/
-
Navigation block – Managing Menushttps://wordpress.org/support/topic/navigation-block-managing-menus/
-
Twenty Sixteen with bleeding edge – Menu drop down going off screen.https://wordpress.org/support/topic/twenty-sixteen-with-bleeding-edge-menu-drop-down-going-off-screen/
-
Twenty Fifteen: Spurious text in Menu Item advanced properties?https://wordpress.org/support/topic/twenty-fifteen-spurious-text-in-menu-item-advanced-properties/
-
Twenty Sixteen with bleeding edgehttps://wordpress.org/support/topic/twenty-sixteen-with-bleeding-edge/
-
Twentyfourteen left menu disappearshttps://wordpress.org/support/topic/twentyfourteen-left-menu-disappears/
-
Gutenberg Table Block removes colspan attributehttps://wordpress.org/support/topic/gutenberg-table-block-removes-colspan-attribute/
-
Gutenberg columnshttps://wordpress.org/support/topic/gutenberg-columns/
-
6.0-RC1-53342 Inline images not aligning properly Twenty Twenty-Two Version: 1.2https://wordpress.org/support/topic/6-0-rc1-53342-inline-images-not-aligning-properly-twenty-twenty-two-version-1-2/
-
5.9 Beta 1: LCP/CLS issue in Twenty Twenty Two themehttps://wordpress.org/support/topic/5-9-beta-1-lcp-cls-issue-in-twenty-twenty-two-theme/
-
Blocked by Content Security Policyhttps://wordpress.org/support/topic/blocked-by-content-security-policy/