如何限制 HTML 选择元素下拉菜单中显示的选项数量?
本质上,HTML 选择下拉列表的长度超过了笔记本电脑上的屏幕,我已经检查过,不同的浏览器允许在将其变成滚动框之前显示不同数量的选项。有什么方法可以放入浏览器 css hack 或 javascript 操作来阻止它的 3 个选项吗?如果失败的话,有什么办法可以限制下拉高度以获得相同的效果吗?
我已经用谷歌搜索过这个问题,但没有这样的运气,以前似乎没有人遇到过笔记本电脑的问题。我知道这是可能的,因为 Lloyds TSB 个人登录屏幕上有一个选择元素,限制了大约 3/4 的选项。正如我所说,我不介意使用 JS 甚至浏览器特定的解决方案,因为我开发了一种笔记本友好的方法,这种方法不太直观且看起来笨重,但可以用作默认值。
任何帮助将不胜感激。
鲁珀特·S.
Essentially the length of the HTML Select drop down is exceeding the screen on notebooks, I've checked and different browsers allow different amounts of options to be displayed before it turns it into a scrollbox. Is there any way of putting in a browser css hack or javascript action to stop it at 3 options? Failing that is there any way to limit the height of the drop down for the same effect?
I've googled up on this but with no such luck, no one seems to have had a problem with notebooks before. I know it's possible as on the Lloyds TSB personal login screen there is a select element which limits to about 3/4 options. As I say I don't mind using JS or even browser specific solutions as I've developed a notebook friendly way of doing it which is less intuitive and clunky looking but can be used as a default.
Any help would be greatly appreciated.
Rupert S.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遗憾的是,您无法更改下拉列表显示的项目,它是由浏览器决定的,使用大小选项它将失去“下拉列表”形式,并将更多内容变成列表。
您可以尝试找到一些 Jquery 下拉列表,它们通常可以编辑为您想要的任何内容。
Sadly, you can't change the item's that the dropdownlist displays, it is decided by the browser, with the size option it will loose its 'dropdownlist' form, and turn more into a list.
You could try finding some Jquery dropdown list, they are usually editable to whatever you want.