如何限制在HTML Select元素下拉菜单中显示的选项数量? [英] How do I limit the number of options displayed in an HTML Select element dropdown menu?

查看:2405
本文介绍了如何限制在HTML Select元素下拉菜单中显示的选项数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,HTML Select下拉菜单的长度超过了笔记本电脑上的屏幕,我已经检查过,不同的浏览器允许不同数量的选项显示之前,它变成一个滚动框。有什么办法放入浏览器的CSS破解或javascript动作停止它在3个选项?没有什么办法可以限制下降的高度,以获得相同的效果?

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?

我已经上了这个,但没有这样的运气,没有人似乎以前有一个问题与笔记本电脑。我知道这是可能的,因为在Lloyds TSB个人登录屏幕有一个选择元素,限制约3/4选项。正如我所说,我不介意使用JS或甚至浏览器特定的解决方案,因为我开发了一个笔记本友好的方式,这是不直观和笨拙的外观,但可以用作默认。

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.

任何帮助将非常感激。

Rupert S。

推荐答案

很遗憾,您无法更改下拉列表显示的项目,它由浏览器决定,使用size选项,它将丢弃其下拉列表表单,并将更多列入列表。

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.

您可以尝试找到一些Jquery下拉列表,他们通常可以编辑任何你想要的。

You could try finding some Jquery dropdown list, they are usually editable to whatever you want.

这篇关于如何限制在HTML Select元素下拉菜单中显示的选项数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆