简体   繁体   English

html5数据集列表高度

[英]html5 dataset list height

Is there any way to limit height for dataset dropdown list?有没有办法限制数据集下拉列表的高度? When I use <input list="datalist"> and the datalist contains many elements, I'm not able to see them all.当我使用<input list="datalist">并且 datalist 包含许多元素时,我无法看到它们。 Can I limit the list size and add vertical scrolling to list all the alternatives?我可以限制列表大小并添加垂直滚动以列出所有备选方案吗?

I searched the web and the only answer I could find was that it's known issue without solution and to avoid it I should use jquery-ui combobox instead.我在网上搜索,我能找到的唯一答案是它是一个没有解决方案的已知问题,为了避免它,我应该改用 jquery-ui 组合框。 I have javascript logic based on dataset so replacment with combo would require much effort.我有基于数据集的 javascript 逻辑,所以用组合替换需要很多努力。

Maybe there is some workaround to achive a limited list in html5?也许有一些解决方法可以在 html5 中实现有限列表?

The short answer is no, there is no easy way to achieve this without JavaScript.简短的回答是否定的,没有 JavaScript 就没有简单的方法来实现这一点。 It is entirely up to the browser to render an input with a datalist.使用数据列表呈现输入完全取决于浏览器。 It will likely differ between browsers and devices as well.它也可能因浏览器和设备而异。

If you go for JavaScript it is a lot of extra work, as you say.正如您所说,如果您使用 JavaScript,则需要做很多额外的工作。 Do not forget about touch devices, keyboard navigation, visually impaired visitors and the tools they use when browsing, etc. Research available alternatives carefully, do not take for granted that they are are all good enough for your users.不要忘记触摸设备、键盘导航、视障访客以及他们在浏览时使用的工具等。仔细研究可用的替代品,不要想当然地认为它们对您的用户来说都足够好。 Unfortunately I do not know which ones to recommend myself.不幸的是,我不知道该向自己推荐哪些。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM