如何设置在SELECT下拉可见项的最大数量? [英] How do I set the max number of items visible in a SELECT drop down?

查看:207
本文介绍了如何设置在SELECT下拉可见项的最大数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个下拉的约30项清单,我想只显示8个项目,然后下拉滚动应。我使用VS2010中MVC2

 <%= Html.DropDownListFor(D => d.Thing.ThingID,Model.Things,新{风格=宽度:200像素,行数= 10})% >


解决方案

你试过尺寸而不是

 <%= Html.DropDownListFor(D => d.Thing.ThingID,Model.Things,新{风格=宽度:200像素,大小= 10})% >

据W3号 http://www.w3schools.com/tags/att_select_size.asp 尺寸就是你要找的属性。

阅读您的回复后,答案似乎是,它是独立于操作系统/浏览器,不可能通过HTML来控制。你可以做的是重写选择框与HTML唯一版本。你可以做这样的事情在这个网站: http://mypocket-technologies.com/jquery/SelectBoxPlugin/ 然而,它可能会导致其他问题,不会看起来像一个标准的列表框。

I have a drop down list of around 30 items and I want to only show 8 items and then the drop down should scroll. I'm using MVC2 in VS2010

<%= Html.DropDownListFor(d => d.Thing.ThingID, Model.Things, new { style = "width: 200px", rows = 10 })%>

解决方案

have you tried size instead of rows?

<%= Html.DropDownListFor(d => d.Thing.ThingID, Model.Things, new { style = "width: 200px", size = 10 })%>

According to the w3 http://www.w3schools.com/tags/att_select_size.asp size is the attribute you're looking for.

After reading your response the answer appears to be that it's operating system/browser independent and not possible to control through html. What you could do is override the select box with an HTML only version. You could do something like on this site: http://mypocket-technologies.com/jquery/SelectBoxPlugin/ However it may cause other problems and won't look like a standard list box.

这篇关于如何设置在SELECT下拉可见项的最大数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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