[英]HTML/PHP one line dropdown list multiple selection
does anyone know a way to create a dropdown list as in a select statement that allows multiple selections but can display on one line. 有谁知道一种在select语句中创建下拉列表的方法,该方法允许多个选择但可以在一行上显示。 Adding the multiple="multiple" option causes it to display on as many lines as there are options which is not suitable for this project's layout Css and/or javascript would be fine however, hoping to avoid js frameworks.
添加multiple =“ multiple”选项会使它显示在与不适合该项目布局的选项一样多的行上。Css和/或javascript很好,但是希望避免使用js框架。 Thinking something with onclick event to show the standard multi-line dropdown box might work but not sure how to implement.
考虑使用onclick事件显示标准的多行下拉框可能会起作用,但不确定如何实现。
Following displays on several lines. 以下几行显示。
<select name="items[ ]" multiple="multiple">
<option value="item1">item1</option>
<option value="item2">item2</option>
<option value="item2">item2</option></select>
I suggest to use select2 which gives you an easy possibility to create such a select-box you need. 我建议使用select2 ,它使您可以轻松创建所需的选择框。 Example from that page fitting your needs:
该页面上的示例符合您的需求:
$(".js-example-basic-multiple").select2();
<select class="js-example-basic-multiple" multiple="multiple">
<option value="AL">Alabama</option>
...
<option value="WY">Wyoming</option>
</select>
请参阅size属性 。
<select multiple="multiple" size="1">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.