Html 限制选择下拉菜单的显示高度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4457232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:43:30  来源:igfitidea点击:

Limiting the displayed height of a select drop-down

htmlcssselect

提问by Josh Smith

I have a <select>with a lot of <option>'s. Is there any way to limit the height of the displayed <select>when opened?

我有<select>很多<option>的。有没有办法限制<select>打开时显示的高度?

回答by scunliffe

the size limit is controlled by the browser and not something you can alter.

大小限制由浏览器控制,而不是您可以更改的。

See this answer: Height of an HTML select box (dropdown)

请参阅此答案:HTML 选择框的高度(下拉列表)

回答by amphetamachine

According to the W3C spec, the sizeattribute will limit the number of visible options in the <select>element.

根据W3C 规范,该size属性将限制<select>元素中可见选项的数量。