-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Cannot scroll down a collapsed navbar on mobile devices #23374
Comments
One quick fix: .navbar-collapse {
max-height: 280px;
overflow-y: auto;
} or (but not all browsers support .navbar-collapse {
max-height: 0.9vh;
overflow-y: auto;
} |
@tmorehouse While this seems to fix the issue in mobile, it seems to create an issue with dropdowns when in full width. |
Might need a few tweaks to the selector to target just when the collapse is opened: .navbar-collapse.collapse.show {
max-height: 280px;
overflow-y: auto;
} |
Thanks it looks like it is "working". But just want to point out that when you resize the browser back to full screen while the collapsed menu is opened, it does the same thing. Looks like the show class is not being cleared. Sorry I don't have time to dig into this. :( |
Probably placing this CSS in a media query, based on the breakpoint used in navbar, would control when this rule is applied. |
|
A |
works for me. If you have another mobile / desktop breakpoint change the media value. |
Try this |
@milossumic's comment on Apr 13th fixed the scrolling issue for me and then broke the drop down menu in the desktop version ... @s4uron's comment on Sep 15, 2017 did fix the issues on mobile devices while not breaking anything extra on the desktop side of things. |
@Dygear You should put it in media query and use it only for smaller screens that you need. Then it won't break on desktop. |
Fix as of Bootstrap 4.1: @media (max-width: 991px) {
.navbar {
overflow: auto;
max-height: 85vh;
align-items: flex-start;
}
} |
I was desperatly searching for a fix for exactly this problem. Thank you so much! |
@danielmarsch This isn't 100% reliable, it can break the desktop version in certain situations. |
@danielmarsch This isn't 100% reliable, it can break the desktop version in certain situations. Use it only on the screen sizes that you need. |
It would be beneficial to get this fix incorporated at some point so anyone could use BootstrapCDN without having to make custom modifications.. |
.navbar {
@media (max-width: breakpoint-max(md)) {
overflow: auto;
max-height: 85vh;
align-items: start;
}
} |
it really works for me thx |
For all navbars:
|
try this it work for me :D ` ` |
I am using this. It avoids horizontal scroll bar and browser default scroll bar while collapsing. You can play with desired vh height of the navbar.
|
I've sassed @NormanHuth solution:
|
The |
Rather than add responsive classes for this, I'm wondering how folks would feel about a |
That looks like a good solution to this. I think my only thought UI wise is how to make it clear that it's scrollable. |
THIS is the only solution which worked for me after trying MANY other solutions (BS 4.5.2). For anyone whose IDE doesn't catch it, there seems to be an erroneous closing bracket on @NormanHuth 's first CSS query? Thank you, thank you!! |
Wonderful, thanks! Tested on 5.0.2 and 5.1.3 without any problems |
When visiting a site using a mobile device with a navbar with .fixed-top, if the opened navbar-collapse area runs beyond the end on the viewport vertically (due to lots of links etc), you cannot scroll down the the links at the bottom of the navbar as you can in Bootstrap 3.
When you do try to scroll, the body behind the navbar scrolls, with the navbar fixed in place.
This can be fixed by setting
overflow-y: auto;
and adding amax-height:Xpx
to the.collapse.show
class and allows you to scroll the navbar-collapse area.This happens in (the ones I tested) major browsers (Safari, Chrome, both on the latest updates). I haven't yet tried whether this fix breaks anything elsewhere.
The text was updated successfully, but these errors were encountered: