限制选择框列表长度-添加滚动条

[英]limiting select box list length - adding scrollbars


When i use an html select box which has about 50 items, I get a very long list that fully appears. I would like to use scrollbars instead. how do I do that?

当我使用一个有大约50个条目的html选择框时,我得到了一个很长的列表。我想用滚动条代替。我该怎么做呢?

3 个解决方案

#1


7  

You need to use CSS, specifically height and overflow:

您需要使用CSS,特别是高度和溢出:

CSS

CSS

.select{
    height:100px;
    overflow:scroll;
}

HTML

HTML

<select class="select"></select>

If you need anything more specific, ask!

如果你需要更具体的东西,可以问!

#2


4  

It is not possible to do this in HTML. See Height of an HTML select box (dropdown)

在HTML中不可能这样做。查看HTML选择框的高度(下拉)

There are other ways of achiving this though javascript or jQuery, with links on that page to some jQuery plugins which create a "fake" html select box that looks and behaves like one, but can have the height set.

通过javascript或jQuery实现这一点还有其他方法,可以在页面上链接到一些jQuery插件,这些jQuery插件创建一个“伪”的html选择框,看起来和行为都像一个框,但可以设置高度。

#3


0  

It is not possible to set the number of visible items for a single value select box. There is a size attribute, but that will transform the dropdown into multiple selection list.

不可能为单个值选择框设置可见项的数量。有一个size属性,但这将把下拉列表转换为多个选择列表。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2011/04/08/c0399a5986ac8b8506db5890f264b44f.html



 
  © 2014-2022 ITdaan.com 联系我们: