Why Is My Dropdown Closing When I Move the Mouse?

Dropdown closes when moving mouse problems usually happen because there is a hover gap between the trigger and the menu, the dropdown is positioned too far away, pointer-events are disabled, or the menu is being covered by another layer.

Dropdown Hover Fix

Why is my dropdown closing when I move the mouse?

A dropdown can open correctly and still close the moment you move your mouse toward it. That usually means the mouse leaves the hover area before it reaches the menu. The most common cause is an invisible gap between the trigger and the dropdown, but z-index, pointer-events, positioning, and mobile hover behavior can create the same frustrating bug.

  • Hover gap
  • Pointer events
  • z-index
  • Mobile menu

What the bug looks like

The dropdown opens on hover, but disappears before your cursor reaches the menu item you want to click.

Why it happens

The hover state is attached to an area that does not include the full path from trigger to dropdown.

What usually fixes it

Remove the hover gap, add a hover bridge, keep the dropdown inside the hoverable parent, and avoid hover-only menus on mobile.

Error 1

There is a gap between the trigger and the dropdown

The dropdown closes because the mouse leaves the hoverable parent while crossing the empty space between the button and the menu. Visually, the gap may look tiny, but to CSS hover it is a complete state break.

Broken code

Hover dead zone
.nav-item {
  position: relative;
}

.dropdown {
  position: absolute;
  top: 70px;
  left: 0;
}

.nav-item:hover .dropdown {
  display: block;
}

Broken visual result

Cursor crosses a dead zone
Products gap
Landing pages Components Templates
The menu disappears because the cursor leaves the hoverable parent before reaching the dropdown.

Correct code

Hover bridge
.nav-item {
  position: relative;
}

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  padding-top: 12px;
}

.dropdown::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
}

Fixed visual result

Safe hover path
Products
Landing pages Components Templates
The dropdown includes a safe invisible bridge, so the hover state does not break.
Error 2

The dropdown is shown on the wrong hover target

If the hover is attached only to the button, the dropdown closes as soon as the cursor leaves the button. The hover should usually live on a wrapper that contains both the trigger and the menu.

Broken code

Button-only hover
.menu-button:hover + .dropdown {
  display: block;
}

.dropdown {
  display: none;
}

Broken visual result

Hover area too small
Services
Design Development Debugging
The menu depends on hovering the button, but the user must leave the button to reach the menu.

Correct code

Wrapper hover
.nav-item:hover .dropdown,
.nav-item:focus-within .dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.nav-item {
  position: relative;
}

Fixed visual result

Wrapper owns the interaction
Services
Design Development Debugging
The hoverable wrapper contains both the trigger and the dropdown, so the menu stays open.
Error 3

pointer-events makes the dropdown unusable

Some dropdowns are hidden with opacity and visibility, but developers forget to restore pointer-events when the menu opens. The result feels like the dropdown closes or cannot be reached, even though it is visible.

Broken code

Clicks pass through
.dropdown {
  opacity: 0;
  pointer-events: none;
}

.nav-item:hover .dropdown {
  opacity: 1;
  /* pointer-events still none */
}

Broken visual result

Visible but not interactive
Account
Profile Settings Logout
Pointer problem The menu can look open but ignore the mouse.
A visible dropdown still needs pointer events enabled when open.

Correct code

Interactive open state
.dropdown {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.nav-item:hover .dropdown,
.nav-item:focus-within .dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

Fixed visual result

Visible and clickable
Account
Profile Settings Logout
The open state should restore opacity, visibility, and pointer events together.
Error 4

The dropdown is hover-only on mobile

Touch devices do not behave like desktop hover. A mobile dropdown that depends only on :hover can open inconsistently, close immediately, or trap the user. Mobile menus usually need a click/tap state.

Broken code

Hover-only mobile menu
.nav-item:hover .dropdown {
  display: block;
}

@media (max-width: 768px) {
  .dropdown {
    position: absolute;
  }
}

Broken visual result

Touch behavior is unstable
Mobile nav

The menu depends on hover, which is not a reliable mobile interaction.

Tap menu
Home Services Contact
Hover-only dropdowns are fragile on touch screens.

Correct code

Click/tap state
.dropdown {
  display: none;
}

.nav-item.is-open .dropdown {
  display: block;
}

@media (hover: hover) {
  .nav-item:hover .dropdown {
    display: block;
  }
}

Fixed visual result

Mobile has its own state
Mobile nav

The menu can use tap/click state on mobile and hover only where hover exists.

Tap menu
Home Services Contact
Use hover as an enhancement, not the only way to open a mobile dropdown.
Premium pattern

A production-minded dropdown hover pattern

A strong dropdown pattern keeps the trigger and menu inside one parent, removes hover gaps, supports keyboard focus with :focus-within, restores pointer events when open, and treats touch screens differently from hover devices.

Premium code

Safe dropdown system
.nav-item {
  position: relative;
}

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  padding-top: 12px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition: .18s ease;
  z-index: 100;
}

.dropdown::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
}

.nav-item:hover .dropdown,
.nav-item:focus-within .dropdown,
.nav-item.is-open .dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

@media (hover: none) {
  .nav-item:hover .dropdown {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .nav-item.is-open .dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

Premium visual result

No hover gap, no panic close
Resources
Guides Components Debug checklist
Premium dropdowns do not depend on a perfect mouse path. They create a safe interaction area.

Fast practical rule

If a dropdown closes when moving mouse, look for the gap first. Move the dropdown closer to the trigger, keep both inside the same hoverable parent, and add an invisible hover bridge before touching complicated JavaScript.

Debug checklist

  • Move the mouse slowly from the trigger to the dropdown and watch where it closes.
  • Check whether there is a visible or invisible gap between the button and the menu.
  • Attach hover to the wrapper that contains both the trigger and the dropdown.
  • Add :focus-within so keyboard users can keep the dropdown open.
  • Restore pointer-events:auto when the menu is open.
  • Check whether another layer is covering the dropdown with a higher z-index.
  • Avoid hover-only behavior on touch screens.
  • Use click/tap state for mobile menus and hover as a desktop enhancement.
Best first move Temporarily give the dropdown area a background color so you can see the hover path.
Most common cause The dropdown is too far below the trigger, creating a dead zone.
Most sneaky cause The menu is visible, but pointer-events:none is still active.
Better mindset Dropdowns need an interaction area, not just a visual box.

Final takeaway

A dropdown closes when moving mouse because CSS hover is unforgiving. If the cursor leaves the hoverable area for even a moment, the dropdown closes. Most of the time, the fix is not complicated JavaScript. It is a better hover area.

Keep the trigger and menu inside one wrapper, remove the gap, add a hover bridge, restore pointer events, and use click/tap state for mobile. The dropdown will feel stable because the interaction path is stable.

Want more fixes like this?

Browse more hover, dropdown, menu, and CSS interaction debugging guides in the FrontFixer library.

Why Is My Dropdown Getting Cut Off?

Dropdown getting cut off problems usually happen when a parent clips overflow, a stacking context traps the menu, or the dropdown is rendered inside a wrapper that was never meant to let children escape.

Dropdown Fix

Why is my dropdown getting cut off even with z-index?

If your dropdown menu opens but gets clipped, hidden, or cut in half, the real problem is usually not that your z-index number is too small. Most dropdown bugs come from overflow:hidden, overflow:auto, a clipped parent, a new stacking context, or a menu rendered inside the wrong part of the DOM.

  • Dropdown clipping
  • Overflow traps
  • Stacking contexts
  • Real UI debugging

What the bug looks like

The dropdown opens, but only part of the menu appears. It may be cut at the bottom of a card, hidden inside a table wrapper, or trapped behind another section.

Why it happens

Dropdowns need visual escape space and correct layering. If a parent clips overflow or creates a new layer boundary, the menu cannot behave like a free floating surface.

What usually fixes it

First separate clipping from layering. If the menu is physically cut off, fix overflow. If it appears behind another element, fix stacking context and z-index.

The mistake: treating every dropdown bug like a z-index bug

A dropdown can disappear for two very different reasons. It can be behind another element, which is a layering issue. Or it can be physically clipped by its parent, which is an overflow issue. A giant z-index:999999 only helps with some layering problems. It does not let a child escape a parent that is cutting visual overflow.

That is why dropdown bugs feel so frustrating. The menu looks like it should float above the page, but the browser still respects the boundaries created by the surrounding layout.

Error 1

Parent overflow is clipping the dropdown

This is the classic dropdown trap. The menu has position:absolute and a huge z-index, but one parent has overflow:hidden. The parent becomes a visual box cutter. The dropdown cannot draw outside that box.

Broken code

Clipped parent
.card {
  position: relative;
  overflow: hidden;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 9999;
}

Broken visual result

Cut by parent
Options ▾
parent edge

The menu exists, but the parent cuts it off before the full dropdown can become visible.

Correct code

Visible overflow
.card {
  position: relative;
  overflow: visible;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
}

Fixed visual result

Menu can escape
Options ▾

Once the parent is no longer clipping the menu, the dropdown can render outside the trigger box.

Error 2

The dropdown is hidden behind another section

This is a real z-index problem, but only after you confirm the menu is not being clipped. If the dropdown is fully visible but appears underneath a neighboring section, header, card, or banner, the menu is losing the stacking battle.

Broken code

Wrong layer
.nav {
  position: relative;
  z-index: 1;
}

.next-section {
  position: relative;
  z-index: 5;
}

.dropdown-menu {
  position: absolute;
  z-index: 2;
}

Broken visual result

Behind section
Next section is above

The menu is not cut by overflow. It is losing against another positioned layer.

Correct code

Higher context
.nav {
  position: relative;
  z-index: 50;
}

.dropdown-menu {
  position: absolute;
  z-index: 60;
}

Fixed visual result

Menu wins layer

The dropdown belongs to a higher positioned context, so it can sit above the next section.

Error 3

A stacking context traps the menu

A dropdown can have a huge z-index and still lose if it is inside a parent stacking context. Properties like transform, filter, opacity, isolation:isolate, and sometimes will-change can create a layer boundary. The dropdown then competes only inside that boundary.

Broken code

Trapped context
.header-wrap {
  transform: translateZ(0);
}

.dropdown-menu {
  position: absolute;
  z-index: 9999;
}

Why this feels impossible

You keep increasing z-index, but the dropdown never escapes. That happens because the menu is not competing against the whole page. It is competing inside the stacking context created by its parent.

If the next section belongs to a higher stacking context, the dropdown can still appear below it even with a massive number.

Error 4

The dropdown is inside a slider, table, or scroll wrapper

Some components clip overflow intentionally. Sliders hide offscreen slides. Responsive tables create horizontal scroll containers. Cards often use overflow:hidden for rounded corners. If your dropdown lives inside one of those wrappers, it may need a structural fix instead of a small CSS tweak.

Classic broken setup

Component clips
.table-scroll,
.slider-track,
.card {
  overflow: hidden;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
}

The better fix

If the wrapper must keep overflow hidden, do not fight that wrapper forever. Move the dropdown outside the clipped element, render it in a higher layer container, or restructure the component so the menu is not trapped by the scrolling or clipping surface.

Advanced pattern

Render the dropdown in a higher layer when needed

In real apps, dropdowns, tooltips, popovers, and menus are often rendered into a dedicated layer near the end of the document. This keeps them away from clipped cards, scroll wrappers, and local stacking contexts.

Layer container idea

Portal style
<div class="app">
  <main>...page content...</main>

  <div class="ui-layer">
    <div class="dropdown-menu">...</div>
  </div>
</div>

Structural visual result

Dedicated UI layer
Dropdown / tooltip / popover layer

The menu is no longer trapped inside the clipped component that triggered it.

Fast practical rule

If your dropdown is getting cut off, do not start by adding bigger z-index numbers. First ask: is the menu clipped or layered behind something? If it is clipped, inspect parent overflow. If it is layered behind something, inspect stacking context. Those are different bugs.

Safer dropdown baseline

Production-minded
.nav {
  position: relative;
  z-index: 50;
  overflow: visible;
}

.nav-item {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  z-index: 60;
}

Why this pattern is safer

The outer navigation has a meaningful stacking level. The item creates a predictable positioning anchor. The dropdown has a clear placement and does not rely on a random massive number. Most importantly, the parent is not clipping the menu.

This does not solve every app architecture, but it gives you a clean baseline before moving to a portal-style or higher-layer solution.

Debug checklist

  • Inspect the dropdown parent chain for overflow:hidden, overflow:auto, and overflow:scroll.
  • Temporarily set suspicious parents to overflow:visible to see whether the menu stops getting cut off.
  • Check whether the dropdown is physically clipped or simply behind another element.
  • Verify the trigger wrapper has a predictable positioning context, usually position:relative.
  • Verify the dropdown has intentional placement, usually position:absolute, top:100%, and left:0.
  • Inspect parents for stacking-context creators like transform, filter, opacity, isolation, and will-change.
  • Check whether the menu is inside a carousel, table wrapper, slider, card, or scroll container that must clip overflow.
  • If the parent must clip overflow, move the dropdown outside that clipped surface instead of fighting the wrapper.
Best first move Use DevTools to toggle parent overflow rules before changing z-index.
Most common false fix Setting z-index:999999 while a parent is still physically clipping the menu.
Most overlooked cause The dropdown lives inside a component that intentionally hides overflow for design reasons.
Better mindset Dropdown bugs are usually structure bugs. Layering is only one part of the diagnosis.

Final takeaway

A dropdown getting cut off is rarely solved by a bigger z-index alone. The real fix starts by identifying whether the menu is clipped by overflow, trapped inside a stacking context, or rendered inside a component that cannot allow visual escape.

Fix clipping first, layering second, and structure third. Once you separate those three problems, dropdown menus become much easier to debug and much less mysterious.

Want more fixes like this?

Explore the full FrontFixer fixes library and keep debugging with practical guides built for real front-end layout problems.