在HTML下拉列表中只显示一些选项

在HTML下拉列表中只显示一些选项

问题描述:

如何在下拉列表中显示10个选项,其余的可以使用滚动条显示?

How can I show 10 option out of 100 in the drop down list and the rest to be available using scrollbar?

非常感谢。

你可以尝试这个小技巧...

You could try this little trick...

<select max="2" onmouseover="this.size = 10" onmouseout="this.size = 1">

它有效地使您的选择下载到鼠标悬停的列表中,并将其重新放回鼠标。

it effectively makes your select drop down into a list on mouse over and puts it back on mouse out.

这是欺骗,可能会弄乱你的HTML定位,但它的工作。

it's cheating and can mess up your html positioning, but it works.

编辑:我很漂亮确保您无法更改单击选择时显示的菜单的大小,这由浏览器决定,而不是由页面控制。

I'm pretty sure you can't change the size of the menu displayed when you click a select, this is determined by the browser and not controllable by the page.