如何设置 SELECT 下拉列表中可见的最大项目数?
我有一个大约 30 个项目的下拉列表,我只想显示 8 个项目,然后下拉列表应该滚动。我在VS2010中使用MVC2
<%= Html.DropDownListFor(d => d.Thing.ThingID, Model.Things, new { style = "width: 200px", rows = 10 })%>
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 })%>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过
size
而不是rows
?根据w3 http://www.w3schools.com/tags/att_select_size.asp size 是您要查找的属性。
阅读您的回复后,答案似乎是它独立于操作系统/浏览器,并且无法通过 html 进行控制。您可以做的是使用纯 HTML 版本覆盖选择框。您可以在此网站上执行类似的操作: http://mypocket-technologies.com/jquery/SelectBoxPlugin/ 但是,它可能会导致其他问题,并且看起来不像标准列表框。
have you tried
size
instead ofrows
?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.