多重选择框中的一个项目比其他项目长得多,有没有办法破解它以使其宽度更小
<select size="1">
<option>item</option>
<option>item</option>
<option>item is really long</option>
<option>item</option>
</select>
Run Code Online (Sandbox Code Playgroud)
您可以使用CSS进行此操作,无论是内联样式还是使用类.
采用内嵌式:
<select style="width: 50px;">
<option>item</option>
<option>item</option>
<option>item is really long</option>
<option>item</option>
</select>
Run Code Online (Sandbox Code Playgroud)
使用课程:
<select class="narrow">
<option>item</option>
<option>item</option>
<option>item is really long</option>
<option>item</option>
</select>
Run Code Online (Sandbox Code Playgroud)
在CSS文件或嵌入式样式表中:
.narrow {
width: 50px;
}
Run Code Online (Sandbox Code Playgroud)
当然,将50px更改为您需要的任何宽度.