我们详细解释这 2 Options 工作


How can I limit the visible options in an HTML dropdown?

How can I limit the number of shown options in an HTML drop down?

How can I get the browser to show only the first five options and scroll down for the rest?

Thank you ! Unfortunately, the size attribute is not what I was looking for because it makes all x options visible. I was trying to avoid javascript for such a little but annoying problem. However, it seems I have no other choice.

yup. I’ve personally never seen it as a problem, as all

i'll never understand how the browser makers are off building WebComponents and whatnot and they can'我们详细解释这 2 Options 工作 t seem to work out something as simple as this. has any developer ever said 'hmm i'd like to limit the number of elements shown in my select dropdown. that ugly list-y thing will do just fine !'

@Petrov: well, what’s the pressing need for web page authors to control the display of a drop-down list so precisely? Can’t the operating system do a fine job of working it out?

The drop-down list can often be too long and makes the list completely unwieldy. And in some cases gets truncated by the visible screen because it doesn't do it right.

11 Answers 11

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

You can 我们详细解释这 2 Options 工作 try this

It worked for me

This does all the resizing correctly, but it crashes IE 11 when selecting a value. Blur works find. Chrome works fine. Any ideas?

You can use the size attribute to make the appear as a box instead of a dropdown. The number you use in the size attribute defines how many options are visible in the box without scrolling.

You can’t apply this to a and have it still appear as a drop-down list though. The browser/operating system will decide how many options should be displayed for drop-down lists, unless you use HTML, CSS and JavaScript to create a fake dropdown list.

Raj_89 solution is the closest to being valid option altough as mentioned by Kevin Swarts in comment it is going to break IE, which for large number of corporate client is an issue (and telling your client that you won't code for IE "because reasons" is unlikely to make your boss happy ;) ).

So I played around with it and here is the problem: the 'onmousedown' event is throwing a fit in IE, so what we want to do, is to prevent default when user clicks the dropdown for the first time. It is important this is only 我们详细解释这 2 Options 工作 time we do this: if we prevent defult on the next click, when user makes his pick, the onchange event won't fire.

This way we get nice dropdown, no flicker, no breaking down IE - just works. well at least in IE10 and up, and latest relases of all the other major browsers.

Few more things to notice: 1) The absolute positioning and setting z-index is helpful to avoid moving other elements when the options 我们详细解释这 2 Options 工作 are displayed. 2) Use 'currentTarget' property - this will be the select element across all browsers. While 'target' will be select in IE, the rest will actually allow you to work with option.

我们详细解释这 2 Options 工作


17.3-inch; FHD 120Hz (1920x1080) or 4K UHD 60Hz (3840x2160)

Launching Eurocom Tornado F7, heavy-duty GPU and CPU upgradeable,Intel Xeon laptop with an all-in-one design with integrated display, keyboard and built-in UPS/battery pack, ensuring you have dedicated on-the-go capability anytime, anywhere. EUROCOM Tornado F7 supports up to 40TB 我们详细解释这 2 Options 工作 of storage with five physical drives in RAID 0/1/5 and up to 128GB of memory.


Author Image


卫星通信系统中的螺旋天线。图片版权属于美国公有领域,通过 Wikimedia Commons 分享。


InSight Mars着陆器的绘画。图片来自 NASA/JPL-Caltech。图片版权属于美国公有领域,通过 Wikimedia Commons 分享。



双臂螺旋天线的 COMSOL 模型。


在 COMSOL Multiphysics® 软件中模拟双臂螺旋天线

此双臂螺旋天线示例使用 COMSOL Multiphysics® 软件的附加组件“RF 模块”进行建模。

如下所示,几何模型包含双臂螺旋辐射器、圆形接地板(蓝色)、调谐短截线、同轴电缆和包围空气域的完美匹配层(PML)。另外,两个螺旋结构沿 z 轴环绕,并在顶端相遇。

使用‘RF 模块’模拟双臂螺旋天线的几何。

在此例中,所有金属部件被建模为理想电导体(PEC),同轴电缆的内部与外部导体之间的空隙充满了聚四氟乙烯(PTFE)。我们利用同轴集总端口来激励天线。此外,所有域(PML 除外)均使用四面体网格进行网格划分,每个波长大概对应 5 个单元,并利用物理场控制网格对吸收方向上的 PML 自动扫掠。


我们计算了两种工作模式下的 S 参数和远场模式:法向模式下的对数电场强度为 0.385 GHz,轴向模式下为 4.77 GHz,参考下方结果绘图。你可以观察天线周围的场强在法向模式(左)和轴向模式(右)下的差异。



天线周围的对数电场强度为 0.385 GHz(法向模式,左)和 4.77 GHz(轴向模式,右)。

接下来,我们看一看 yz 平面的二维辐射方向图的极坐标图。该图显示了两种工作模式。不出所料,你可以看到偶极天线在法向模式下的经典 E 平面方向图(蓝色)和在轴向模式下的定向辐射方向图(绿色)。


yz 平面的远场模式的极坐标图,法向模式显示为蓝色,轴向模式显示为绿色。

此外,你还可以利用 3D 远场绘图对每个模式进行三维远场辐射图可视化处理。两种模式的 S 参数均小于 -10 dB。观察三维远场方向图,可以发现这些结果再次证明了法向模式下的偶极天线形状和轴向模式下的端射式阵列形状是合理的。



螺旋天线在法向模式(左)下的三维远场方向图与偶极天线相似。轴向模式(右)下的三维远场方向图与由接地平面支撑的、沿 z 轴方向的端射式阵列天线类似。

下方轴比图显示了天线的圆极化程度。当天线被表征为理想圆极化时,轴比为 1 或 0dB。当小于 3 我们详细解释这 2 Options 工作 dB(红色圆圈内)时,我们通常认为天线是圆极化。下图中,天线视轴处的轴比小于 3 dB。天线视轴是轴向模式的主要传播方向,它平行于螺旋状的扭转轴。


以 dB 为单位的轴比(蓝色),红线表示 3 dB。

想尝试螺旋天线建模吗?点击下方按钮即可开始。跳转到“案例下载”页面后,请登录 COMSOL Access 帐户下载 MPH 文件(需要有效的软件许可证)。

Bootstrap Form Inputs

Bootstrap supports all the HTML5 input types: text, password, datetime, datetime-local, date, month, time, week, number, email, url, search, tel, and color.

Note: Inputs will NOT be fully styled if their type is not properly declared!

The following example contains two input elements; one of type text and 我们详细解释这 2 Options 工作 one of type password:


Bootstrap Textarea

The following example contains a textarea:


Bootstrap Checkboxes

Checkboxes are used if you want the user to select any number of options from a list of preset options.

The following example contains three checkboxes. The last option is disabled:我们详细解释这 2 Options 工作


Use the .checkbox-inline class if you want the checkboxes to appear on the same line:


Bootstrap Radio Buttons

Radio buttons are used if you want to limit the user to just one selection from a list of preset options.

The following example contains three radio buttons. The first option is checked by default and the last option is disabled:


Use the .radio-inline class if you want the radio buttons to appear on the same line:


Bootstrap 我们详细解释这 2 Options 工作 Select List

Select list (select one):
Multiple select list (hold ctrl or shift (or drag with the mouse) to select more than one):

Select lists are used if you want to allow the user to pick from multiple options.

The following example contains a dropdown list (select list):


We just launched
W3Schools videos



Get certified
by completing
a course today!


Report Error

If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

Thank You For Helping Us!

Your message has been sent to W3Schools.

Top Tutorials
Top References
Top Examples
Web Courses

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.