-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nav items overflowing navbar on medium viewports #1271
Comments
i think this problem can be solved by this way:https://stackblitz.com/edit/vitepress-theme-issue-navbarmenulink-5bjtqp?file=index.md |
That prevents text wrapping, so you don't get the "nav item becauses twice the height of the navbar" problem, but then the nav items will overflow the navbar and make other items go out of view much quicker. I think my fix in #1273 is a better approach. |
Thanks for the report and also the PR, but I really think the right approach to this is to "change the title & menu structures". There's no way we can fit an unlimited number of menus. So, if it gets over-wrapped, users should consider grouping them into a dropdown menu or shortening the labels. It is all about balance. For example, if you have lots of social links, you will get less space for menu items too. Sometimes, the content has to adjust to the design. Or, even better, create own custom nav bar that can display the long texts 👍 |
I disagree. IMO designs should be implemented to be resilient to not-so-extreme cases, in line with the spirit of responsive design (see also: defensive CSS. Oftentimes that's necessary to meet WCAG AA requirements too. The current design breaks easily with just ~3 items when those items are not short single word labels, and it currently breaks for two localizations of the Vite docs: Spanish (the "…" menu is pushed to the right, outside of the viewport): Chinese (showing the line-height issue again, with label wrappings to two lines, with huge gaps between lines): |
Describe the bug
When using the default theme, the navbar items are hidden away in a menu on screen widths lower than 768px.
At 768px and slightly larger sizes, the navbar may have to render on one line:
algolia
options)When the nav items don't fit, their text may wrap, and their extreme
line-height
makes that result particularly bad:Reproduction
Expected behavior
There are two levels of fixes:
Mitigate the breakage when nav items do wrap.
line-height
(that's a bad way to do vertical centering of text, for the reason demonstrated in this issue).min-height: var(--vp-nav-height-mobile); line-height: normal;
(plus probably a tad ofpadding-block
).If the nav items still overflow their container, what should happen? Should they be clipped (
overflow: hidden
on the container), or should the container height grow (i.e. the container should be usingmin-height
and notheight
)? Clipping might be better to conserve the design, but note that it's a WCAG violation (loss of content).Prevent this situation altogether:
System Info
Additional context
I can probably do a PR for the line-height part at least.
Validations
The text was updated successfully, but these errors were encountered: