简体   繁体   English

HTML5选择多个高度以适合内容

[英]HTML5 Select Multiple Height To Fit Content

We a trying to get a select input element with multiple attribute set on, to automatically resize to fit its content. 我们试图获得一个select输入元素,该select输入元素设置了multiple属性,以自动调整大小以适合其内容。

We have noticed that when setting the select element multiple to true, we can then change the styling of the child option elements. 我们注意到,当将select元素的multiple设置为true时,我们可以更改子option元素的样式。

<select multiple>
   <option>A</option>
   <option>B</option>
   <option>C</option>
</select>

This is great because we can create a more customized user experience... 这很棒,因为我们可以创建更多定制的用户体验...

select option{
   display : inline-block;
   padding : 5px;
   border-radius : 3px;
}

But the problem is that the size is interpreted by the browser to be "3" and so the height is being set accordingly... 但是问题在于浏览器将尺寸解释为“ 3”,因此高度被相应地设置...

Is there a way to make the select to auto resize to fit the content? 有没有办法使选择内容自动调整大小以适合内容?

Thanks in advance... 提前致谢...

I think you can take a look here : Multi-Selection horizontal 我想您可以在这里看看: 多选水平

Depends on what you want to do ! 取决于你想做什么!

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

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