Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap dropdown clipped by overflow:hidden container, how to change the container?

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/

like image 208
AlBaraa Sh Avatar asked Aug 05 '15 10:08

AlBaraa Sh


People also ask

What container element do you use to create the drop down content?

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 .

How do I center a drop down menu in bootstrap?

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.

What is drop down in bootstrap?

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.


1 Answers

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/

like image 147
Varol Avatar answered Sep 28 '22 09:09

Varol