现在此下拉层高度是自适应,有多少数据就列多长。想怎么设置高度,让多余的数据用滚动跳查看。
2条回答 默认 最新
- canyoufeel75 2012-04-10 17:20关注
给你找的源码 有这个效果的 max-height
<!DOCTYPE html>
jQuery UI Autocomplete - Scrollable results
<br> .ui-autocomplete {<br> max-height: 100px;<br> overflow-y: auto;<br> /* prevent horizontal scrollbar <em>/<br> overflow-x: hidden;<br> /</em> add padding to account for vertical scrollbar <em>/<br> padding-right: 20px;<br> }<br> /</em> IE 6 doesn't support max-height<br> * we use height instead, but this forces the menu to always be this tall<br> */<br> * html .ui-autocomplete {<br> height: 100px;<br> }<br>
<br> $(function() {<br> var availableTags = [<br> "ActionScript",<br> "AppleScript",<br> "Asp",<br> "BASIC",<br> "C",<br> "C++",<br> "Clojure",<br> "COBOL",<br> "ColdFusion",<br> "Erlang",<br> "Fortran",<br> "Groovy",<br> "Haskell",<br> "Java",<br> "JavaScript",<br> "Lisp",<br> "Perl",<br> "PHP",<br> "Python",<br> "Ruby",<br> "Scala",<br> "Scheme"<br> ];<br> $( "#tags" ).autocomplete({<br> source: availableTags<br> });<br> });<br>Tags:When displaying a long list of options, you can simply set the max-height for the autocomplete menu to prevent the menu from growing too large. Try typing "a" or "s" above to get a long list of results that you can scroll through.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报