限制選擇框列表長度-添加滾動條

[英]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 联系我们: