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条)

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用