html5 datalist wont dropdown when the sugguest list is large

会有一股神秘感。 提交于 2019-12-08 03:23:53

问题


I use datalist to suggest a selection of data to a specific text input, but when the size of the datalist got too large( I don't know the right number yet, but quite sure when the size is larger than 40 this will happen).

I use datalist as following

<datalist id="citysuggest">
    <option value="北京">
    <option value="锦州">
    <option value="唐山">
    <option value="天津">
    <option value="清远">
    <option value="盘锦">
    <option value="成都">
</datalist>
<input type="text" list="citysuggest"  name="name1" value="" />

here shows when size not "too large", datalist can dropdown when click the down-arrow button.

but when datalist is "too large" (in this example the real number is 42), it wont dropdown a suggest list when click the down-arrow button.

For the record, this happened with Linux Chrome browser Version 39.0.2171.95

any suggestion to fix that?


回答1:


I believe this is caused by a known Cromium bug:




回答2:


Enclosed your datalist to a div and put overflow:

<div style="overflow-x: hidden; overflow: scroll; width: 100%; height:500px"> 
       <datalist id="citysuggest">
    <option value="北京">
    <option value="锦州">
    <option value="唐山">
    <option value="天津">
    <option value="清远">
    <option value="盘锦">
    <option value="成都">
</datalist>
<input type="text" list="citysuggest"  name="name1" value="" />
</div>

Hope this helps!



来源:https://stackoverflow.com/questions/27598876/html5-datalist-wont-dropdown-when-the-sugguest-list-is-large

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!