v_jgxu 2012-04-09 09:17
浏览 379
已采纳

jquery ui内autocomplete中的combobox如何设置下拉层高度

现在此下拉层高度是自适应,有多少数据就列多长。想怎么设置高度,让多余的数据用滚动跳查看。

  • 写回答

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&#39;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> &quot;ActionScript&quot;,<br> &quot;AppleScript&quot;,<br> &quot;Asp&quot;,<br> &quot;BASIC&quot;,<br> &quot;C&quot;,<br> &quot;C++&quot;,<br> &quot;Clojure&quot;,<br> &quot;COBOL&quot;,<br> &quot;ColdFusion&quot;,<br> &quot;Erlang&quot;,<br> &quot;Fortran&quot;,<br> &quot;Groovy&quot;,<br> &quot;Haskell&quot;,<br> &quot;Java&quot;,<br> &quot;JavaScript&quot;,<br> &quot;Lisp&quot;,<br> &quot;Perl&quot;,<br> &quot;PHP&quot;,<br> &quot;Python&quot;,<br> &quot;Ruby&quot;,<br> &quot;Scala&quot;,<br> &quot;Scheme&quot;<br> ];<br> $( &quot;#tags&quot; ).autocomplete({<br> source: availableTags<br> });<br> });<br>

    Tags:

    <!-- End demo -->

    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.

    <!-- End demo-description -->


    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大