简体   繁体   English

JQuery UI自动完成(1.8)滚动

[英]JQuery UI Autocomplete (1.8) scroll

i'm having troubles configuring the autocomplete module of JQuery-UI. 我在配置JQuery-UI的自动完成模块时遇到了麻烦。 I need that when the amount of data to select is big enough an scroll bar appears. 我需要当要选择的数据量足够大时会出现滚动条。

This is what i tried: 这是我试过的:

  • in the jquery-ui-1.8.16.css i've set this: jquery-ui-1.8.16.css我设置了这个:
ui.autocomplete{
    max-height: 100px;
    overflow-y: auto;
    overflow-x: hidden;
}

*as shown in the ui-documentation example *如ui-documentation示例中所示

This is how i declare and autocomplete input: 这是我声明和自动完成输入的方式:

$("#myInput").autocomplete({
    source: mySource,
    minLength: 0,
});

I dont know why the scroll bar does not appear, any help would be appreciated. 我不知道为什么滚动条没有出现,任何帮助将不胜感激。 Thank you very much! 非常感谢你!

You should override the css setting it in the page like this 您应该像这样覆盖在页面中设置它的CSS

<style>
.ui-autocomplete {
    max-height: 100px;
    overflow-y: auto;
    /* prevent horizontal scrollbar */
    overflow-x: hidden;
    /* add padding to account for vertical scrollbar */
    padding-right: 20px;
}
/* IE 6 doesn't support max-height
 * we use height instead, but this forces the menu to always be this tall
 */
* html .ui-autocomplete {
    height: 100px;
}
</style>

instead of changing values in jquery-ui-1.8.16.css 而不是在jquery-ui-1.8.16.css中更改值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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