如何使列表框足够高以适应所有选项(最好隐藏滚动条)?
设置大小等于长度,但如果长度是动态的,那么这是一种简单的方法吗?
答案 0 :(得分:0)
因此,您无法仅使用选择标记隐藏滚动条。你需要添加一个div来覆盖它
HTML:
<div class="opt">
<select multiple='multiple'size=11>
<option selected>Select</option>
<option>This is an option</option>
<option>This is another Option</option>
<option>This is another Option</option>
<option>This is another Option</option>
<option>This is another Option</option>
<option>This is another Option</option>
<option>This is another Option</option>
<option>This is another Option</option>
<option>This is another Option</option>
<option>This is another Option</option>
</select>
</div>
的CSS:
.opt {
display:inline-block;
vertical-align:top;
overflow:hidden;
border:solid grey 1px;
}
.opt select {
padding:10px;
margin:-5px -20px -5px -5px;
}