简体   繁体   中英

how can I make sure a dropdownlist's list is always dropped down rather than up

I want to show dropdownlist always to down. (Is it posible?)

If bottom space is less then the height of dropdown list it's show list to up.

I want to show list always to down.

Thanks in advance

This can be achieved by adding the following attribute to your CSS class of your dropdown list:

.drop-down {
    top:100%; 
}

The same can be used to force the list to go upwards: bottom: 100%;

Here is a jsfiddle demo .


EDIT:

The standard HTML form Select Option ( <select><option> <option></select> ) can not be manipulated to expand into a certain direction. You'll have to write your own custom dropdown menu with JavaScript to implement this functionality.

After a quick browse I've noticed that others have struggled with the problem you're having. And apparently the following CSS code seems to fix it in some cases.

select { vertical-align: top; }

What you can do is set the attr size using jQuery like so

jsFiddle : https://jsfiddle.net/ou5n9u3y/

jQuery

$(function () {
    var dropdownOptions = $('.dropdown-selector').find('option').length;
    $('.dropdown-selector').attr('size', dropdownOptions);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM