Using bootstrap, I have a dropdown menu(s) inside a div
with overflow:hidden
, which is needed to be like this. This caused the dro
Change the div property to overflow:visible;
, or Set Position:absolute;
on .dropdown class like
.bs-example .dropdown{position:absolute;}
See the Working Code: http://jsfiddle.net/guruWork/3x1f8ng5/
I ended up using tippy.js insead of bootstrap dropdown, which solved this overflow:hidden parent problem, since dropdown can be located in body tag.
For anyone struggling with the same issue, but using ng-bootstrap, here's a solution for you - use container="body"
option in your ngbDropdown
:
<div ngbDropdown container="body">
<!-- Dropdown menu goes here -->
</div>
All the answers mentioned here didn't work for me, so I found another workaround:
$('.dropdown').on('shown.bs.dropdown', function () {
const dropdown = $(this);
setTimeout(function () {
dropdown.find('.dropdown-menu').css({'top': dropdown.offset().top - $(window).scrollTop(), 'left': dropdown.offset().left - $(window).scrollLeft(), 'position': 'fixed'});
}, 1);
});
The timeout is necessary as the event handler is fired before bootstraps sets the CSS of the dropdown therefore overwriting it
Changing the container is possible using jQuery e.g. $(".dropdown").insertAfter(".bs-example");
See this code for example: https://jsfiddle.net/SolveItSimply/pwmyvsw6/
I don't recommend this though, as you will lose any of the usefulness of Bootstrap positioning and keeping the drop-down elements in order will be messy.
Instead, you could use overflow:visible
along with the 'hidden' class to your advantage, hiding any element that overflows with JavaScript. Here's an example: http://jsfiddle.net/SolveItSimply/z14c210x/
You will need to check the contained elements when the div is first visible and whenever the height of the container changes, which I've tried to demonstrate in my example.
I had a div
element with a Bootstrap panel
class containing DevExpress ComboBoxes
contained in div
elements with Bootstrap col-lg
classes.
I had a problem of the panel
background color or border color bleeding to the div
above. To resolve that I added overflow:hidden;
to the panel
but that caused the ComboBox's dropdown to be cut off. I added style="position: inherit"
to those div elements within the panel
containing the ComboBoxes and that solved the problem.
<div class="col-sm-12" style="position: inherit">
<div class="col-sm-4" style="position: inherit">
<dx:aspxComboBox></dx:aspxComboBox>
</div>
</div>
This solution I found here.