Your dropdown menu is stretching off the screen because it's set to 100vw, which includes the browser's scrollbar width, causing horizontal overflow or misalignment.
1. Use 100% Width Instead of 100vw
- Change the dropdown menu's width from 100vw to 100%.
- This makes the dropdown menu only as wide as its parent container, preventing it from exceeding the visible viewport.
2. Align the Dropdown Menu with Relative Positioning
- Make sure the Dropdown Wrapper or Parent Menu Item has position: relative.
- Set the dropdown’s position to absolute. This ensures that 100% width refers to the parent's width.
3. Set Overflow Hidden on Parent Container (if needed)
- If the menu still causes horizontal scrolling, set overflow-x: hidden on the Body or root container, not the dropdown.
- This prevents unwanted horizontal scroll caused by overflowing elements.
4. Use a Max-Width If You Need Full Screen Look
- If you're aiming for a full-width dropdown effect, set:
- Width: 100%
- Max-width: 100vw
- This prevents it from exceeding the viewport due to scrollbars or padding/margin issues.
5. Avoid Fixed Padding or Margins That Add Width
- Check and remove any left/right margins or paddings on the dropdown that could cause it to overflow.
- Consider using padding within the dropdown content, not on the container itself.
Summary
To make your dropdown full-width without misalignment or overflow, use width: 100% instead of 100vw, ensure its parent has relative positioning, and watch out for any extra margins or padding that could add unwanted width.