Using bootstrap, I have a dropdown menu(s) inside a div
with overflow:hidden
, which is needed to be like this. This caused the dropdowns to be clipped by the container.
My question, how can I solve this clipping issue, e.g. change the container of all dropdowns inside my project to be body
, with lowest cost possible?
this is an example of the code: http://jsfiddle.net/0y3rk8xz/
Use a container element (like <div>) to create the dropdown content and add whatever you want inside of it. Wrap a <div> element around the elements to position the dropdown content correctly with CSS. CSS) The .
Dropdown button can be positioned in the center of the page by setting the “text-align” property of dropdown div to center. The following example contains a simple Bootstrap dropdown menu with an added class “my-menu”. The property “text-align: center” is added to the class.
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap dropdown JavaScript plugin. They're toggled by clicking, not by hovering; this is an intentional design decision.
if anyone interested in a workaround for this, bootstrap dropdown has a show.bs.dropdown event you may use to move the dropdown element outside the overflow:hidden
container.
$('.dropdown').on('show.bs.dropdown', function() { $('body').append($('.dropdown').css({ position: 'absolute', left: $('.dropdown').offset().left, top: $('.dropdown').offset().top }).detach()); });
there is also a hidden.bs.dropdown event if you prefer to move the element back to where it belongs once the dropdown is closed:
$('.dropdown').on('hidden.bs.dropdown', function() { $('.bs-example').append($('.dropdown').css({ position: false, left: false, top: false }).detach()); });
Here is a working example:
http://jsfiddle.net/qozt42oo/32/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With