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
jesus christ people yall take something so simple and make it complicated. Change the dropdown position to position:static; and BLAMMMMMMM! Problem fixed. I think I saw someone else mention this but then they were drowned out by overly bloated and hackish fixes :(
I faced the same issue, with needing to have overflow:hidden
set, but yet have the drop-down not be clipped.
However my situation involved the Bootstrap Carousel, so I decided a valid solution would make the overflow visible only when the dropdown is opened, and when it closes, the overflow can return to hidden. This solution might work for others, so I'm sharing it.
$('.dropdown-toggle').click(function() {
var $container = $(this).parent('.carousel-inner');
$container.css('overflow','visible');
$(document).one('click', function() {
$container.css('overflow','');
});
});
Note, this doesn't check for Esc
key being used to close the dropdown, but in my case this wasn't an issue. My own version uses a class to apply the style which some devs might prefer instead of modifying inline CSS.
You can also try this one by replacing yourDivId by the id of your div.
$('.dropdown').on('show.bs.dropdown', function() {
$('#yourDivId').css('overflow-x', 'visible');
});
$('.dropdown').on('hidden.bs.dropdown', function() {
$('#yourDivId').css('overflow-x', 'hidden');
});
I was facing the same issue and after searching for hours.. I created a event handler to catch the dropdown-toggle and get the positions and attach it dynamically. so that it doesnt get cut off.
Here is the simple code I used. Try it out if this helps.
$('.dropdown-toggle').click(function (){
dropDownFixPosition($('button'),$('.dropdown-menu'));
});
function dropDownFixPosition(button,dropdown){
var dropDownTop = button.offset().top + button.outerHeight();
dropdown.css('top', dropDownTop + "px");
dropdown.css('left', button.offset().left + "px");
}