如何使所有选项在< select>中可见标签 [英] how to make all options visible in a <select> tag

查看:87
本文介绍了如何使所有选项在< select>中可见标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在html中制作 long (> 20选项)下拉列表,因此我使用< select>标签。但超过20项,Firefox(其中包括)将添加一个滚动条,我希望所有选项都可见。我尝试使用css overflow 属性,但它不起作用。

I need to make a long (>20 options) drop-down list in html, so I use the <select> tag. But over 20 items, Firefox (among others) will add a scrollbar, and I want all the options to be visible. I tried to play with the css overflow property, but it won't work.

任何简单的html / css解决方案,在我投降之前Javascript?

Any simple html/css solution, before I surrender to Javascript?

(注意:< select>标记的 size =n属性不会生成下拉列表;它使得 n 选项始终可见 :不是我想要的)

(note: the size="n" property of the <select> tag doesn't make a drop-down list; it makes n options visible all the time: not what I want)

推荐答案

在使用滚动条之前,没有办法告诉浏览器需要列出多少个选项。 HTML和CSS没有任何关于此的信息。

There isn't a way to tell the browser how many options to list before using a scroll-bar. HTML and CSS do not have anything regarding this.

如果您真的想要这种行为,您必须实现自己的弹出窗口显示列表。

If you really want this behavior, you'd have to implement your own pop-up displaying the list.

这篇关于如何使所有选项在&lt; select&gt;中可见标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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