bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Big Dropdowns don't fit in the page

Open uanjoze opened this issue 14 years ago • 16 comments

Hi,

I don't know if it's a bug, or if the dropdown menu is meant only for 4 or 5 items, but when the page height is smaller than the height of the list of items in a dropdown it's impossible to reach the items that don't show (and since its position is "fixed", it can't be scrolled down to)

Thanks for Boostrap guys!

uanjoze avatar Jan 09 '12 18:01 uanjoze

How big are they? Or how small is your website?

pokonski avatar Jan 09 '12 18:01 pokonski

Well, it's a Control Panel and for "technical reasons" I can't change the number of items (the longest drop-down has 32 menu items), and once those items are below the lower edge of the browser nothing can be done. I thought of adding some JS so it'd detect the height of the screen and drop-down and make the latter scrollable.

Even if the page is scrollable, the drop-down stays fixed to the browser's window (I think that's what you meant by "how small is your website")

uanjoze avatar Jan 09 '12 18:01 uanjoze

I get it, fixed = no scrolling :(

pokonski avatar Jan 09 '12 18:01 pokonski

Ideally you would control the number of items there, but I understand the limitations some folks are operating within. Perhaps I can explore adding a max-height and doing a scrollbar within them to allow for such situations.

Sound reasonable?

mdo avatar Jan 09 '12 20:01 mdo

@markdotto: Rather than pick an arbitrary max-height that is just as likely to not fix Person X's site as it is to fix @juanjodominguez's problem, I would recommend recommending (mouthful, there) that people likely to be affected by this simply write their own window load/resize watcher which sets a dynamic max-height based on viewport height. You/Bootstrap can perhaps offer a sample bit of JS for this, but I would think hard-coding in a max-height is just as likely to hurt some people as help others. Better to help those really hurt by it help themselves.

IMO.

Edit: Unless max-height on a position:fixed element can be expressed in %. In which (unlikely) case, bully for that.

reefdog avatar Jan 09 '12 23:01 reefdog

@markdotto: That's what I had in mind, but as @reefdog says, having JS work that max-height out

uanjoze avatar Jan 10 '12 12:01 uanjoze

Dropdowns are a tricky thing. Their contents need to be well considered and in the future we could add this to our dropdowns plugin perhaps, but the first solution will be CSS.

mdo avatar Jan 10 '12 23:01 mdo

@markdotto: Do what you must. I agree with CSS > JS, but my larger point was that a hard-coded arbitrary max-height is rigid and has its own cons. What constitutes an appropriate max-height will be different for nearly every site and viewport. I'd personally say "sorry, no max-height by default; if you need it, you can choose your own or roll a JS solution". But again, do what you think is right.

reefdog avatar Jan 11 '12 17:01 reefdog

The only way to do it via CSS is to overflow: hidden; and that cuts off the little caret at the top of dropdowns. Not idea and not something we can easily do for everyone. We'll re-evaluate after the launch of 2.0 and perhaps have another solution.

Until then, do your best to avoid super long dropdowns.

mdo avatar Jan 15 '12 01:01 mdo

I've managed this issue by using 2 or 3 cols in the dropdown. It's works pretty well ;)

antoineguiral avatar Jan 17 '12 23:01 antoineguiral

@antoineguiral Would you mind sharing the CSS/HTML code for 2 columns in the dropdown? I'm facing the same situation :)

erlingur avatar Mar 04 '12 16:03 erlingur

+1 about sharing the CSS to create 2/3 column drop down menus

laurenty avatar Jul 01 '12 00:07 laurenty

+1 about sharing the CSS to create 2/3 column drop down menus

Dinesh-Ramakrishnan avatar Nov 08 '12 13:11 Dinesh-Ramakrishnan

1 about sharing the CSS to create 2/3 column drop down menus. I did find this post, but this is not created/adjusted for bootstrap.

WvanLelyveld avatar Nov 22 '12 10:11 WvanLelyveld

WvanLelyveld (and everyone interested): I followed that link, too, and it works GREAT for a Twitter-powered website. Just put the CSS code in a custom.css file and include it in your page (so to avoid the changes being overwritten when updating bootstrap code). I wish I had found this page sooner but instead I had to comb through Google's results.

BBaFSE avatar Nov 24 '12 05:11 BBaFSE

Nice.. You are right, it works fine. To make sure people can still find this when the link breaks, I put the code here:

Hi,

Not sure if is the right approach but you can start with this, I've used it for nav dropdown but you can adapt it for button.

HTML part:

<li class="dropdown open">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu <i class="icon-chevron-down"></i></a>
    <ul class="dropdown-menu span6">
        <li class="column-menu span3 firstcolumn">
            <ul>
                <li><a href="#">Item</a></li>
                <li><a href="#">Item</a></li>
                <li><a href="#">Item</a></li>
                <li><a href="#">Item</a></li>
            </ul>
        </li>
        <li class="column-menu span3">
            <ul>
                <li><a href="#">Item</a></li>
                <li><a href="#">Item</a></li>
                <li><a href="#">Item</a></li>
                <li><a href="#">Item</a></li>
            </ul>
        </li>
    </ul>
</li>

CSS part:

.navbar .dropdown-menu [class*="span"] {
    padding-top: 10px;
}
.navbar .dropdown-menu > li.column-menu ul {
    display: inline-block;
    list-style: none outside none;
    margin: 0 0 16px;
    width: 100%;
}
.navbar .dropdown-menu > li.column-menu li {
    display: inline;
    float: left;
    width: 100%;
}
.navbar .dropdown-menu > li.column-menu.firstcolumn {
    margin-left: 0;
}


Regards,
Raul.
- show quoted text -
-- 
Raul Matei
+40741351728

Props to Raul.

WvanLelyveld avatar Nov 24 '12 11:11 WvanLelyveld