-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Dropdown and popover position based on offset #1411
Comments
My nav bar is positioned at the bottom instead of the top, and the dropdowns are all off-screen. +1 for this. Edit: found a bottom-up class in the css files that solves my problem. Looks like there's no documentation for this yet. |
This is a bit of an issue. You can see in this screenshot for any popover element close to the right-side of page, that the popover goes off-page, lost in some dark corners of computer screens, far, far away (from sight). |
I have a similar issue with a dropdown near the end of the screen on the right. It opens and you can only see a little bit of it before it fades out of view. It would be nice if it could guess whether to open on the bottom-right, bottom-left, top-right, or top-left. |
+1 |
2 similar comments
+1 |
+1 |
+1 - this is especially a problem on my Droids (dont have an iPhone)... but with the narrow strip of content, it seems to almost always be appearing outside the viewport. |
You just need to provide a custom position function. There's one floating around in the github issues if you search a bit, or you could try the mailing list :) |
This fixes it if you do an inline style adjustment: <ul class="dropdown-menu" style="right: 0; left: auto;"> |
A custom position function and inline styles are messy. Wan't offset included in v1 of bootstrap? I don't think it's an unreasonable request. |
I do need offset to achieve corner positionning (cf. #2915). Please add it or allow use to set (or return via a lambda) an object {top, left} instead of only strings so we can position stuff more precisely. |
The existing custom position function fat talked about is here : #345 |
The dropdown function doesn't seem to support a position function, so what would be the preferred way to handle positioning for a dropdown? |
If your menu is on the right then use dropdown-menu pull-right this specifies the inline style suggested by cavneb. |
What about menus that are triggered from in-page content, meaning that the user can have scrolled to a point where the menu is not visible when clicked? |
Bootstrap menus close when they lose focus so if a user scrolls to a point where the menu is not visible and interacts with any other object the menu will close. I don't know if this is what you were asking. |
No, I mean something like a button on a page, that when the page is scrolled down will be at the top of the screen and would therefore naturally have the menu display below it, but when the page is scrolled up, the button would be at the bottom of the screen and the menu would then open outside of the viewport since its position is static. |
You may have to build a custom javascript to handle this situation to toggle class .bottom-up which supposedly pushes the menu up instead of down. I have not tested this. |
The function @fat was talking about is this
However, I'd recommend not using |
@archonic, I found that function as well, but since dropdown doesn't support a position function, it's of no use for that widget. Haven't tested it for popover, where I assume it works as desired. |
I see what you mean. Could you use |
@archonic I probably could, but in the meantime I've worked around it in the design. I'll return with more if I hit the problem again later. |
While this doesn't work based on offset, if you KNOW where you want it to open, I modified the bootstrap CSS to allow a data-placement="left" on the .dropdown-menu element. Then you just add this after loading bootstrap's CSS:
|
I describe a JavaScript based solution for this problem in #10756 (comment) |
+1 this should be included by default, or provided via an option (data or class) |
For dropdowns to go up just use |
This is not a priority but it would be useful to Open dropdowns and popovers based on current position: for example if the popover toggle is positioned at the top of the page open the popover with position: bottom so that popovers and dropdiwns will be always visible.
I thought about jquery .offset()
The text was updated successfully, but these errors were encountered: