我有一个下拉菜单,其中选择和选项标签的宽度不同:-
#select{
width:150px;
>option{
width:210px;
}
}
此代码在除 IE7 和 IE8 之外的所有其他浏览器中运行良好。在这些浏览器中,选项标签也使用宽度为 150 像素。如何解决这个问题?请帮忙....
我有一个下拉菜单,其中选择和选项标签的宽度不同:-
#select{
width:150px;
>option{
width:210px;
}
}
此代码在除 IE7 和 IE8 之外的所有其他浏览器中运行良好。在这些浏览器中,选项标签也使用宽度为 150 像素。如何解决这个问题?请帮忙....
我发现的一个示例仅使用 css 和一点 javascript 来更改 onclick 的宽度。
<style>
.ctrDropDown{
width:145px;
font-size:11px;
}
.ctrDropDownClick{
font-size:11px;
width:300px;
}
.plainDropDown{
width:145px;
font-size:11px;
}
</style>
<div style="padding:4px;width:175px;height:75px;border:thin solid black;overflow:hidden;">
I am the problem select list:<br><br>
<select name="someDropDown" id="someDropDown" class="plainDropDown">
<option value="">This is option 1.</option>
<option value="">This is the second option, a bit longer.</option>
<option value="">Drink to me only with thine eyes, and I will pledge with mine...</option>
</select>
</div>
<br>
<hr width="150px;" align="left">
<br>
<div style="padding:4px;width:175px;height:75px;border:thin solid black;overflow:hidden;">
I am the better select list:<br><br>
<select name="someDropDown" id="someDropDown" class="ctrDropDown" onBlur="this.className='ctrDropDown';" onMouseDown="this.className='ctrDropDownClick';" onChange="this.className='ctrDropDown';">
<option value="">This is option 1.</option>
<option value="">This is the second option, a bit longer.</option>
<option value="">Drink to me only with thine eyes, and I will pledge with mine...</option>
</select>
</div>
也是一个 JSFIDDLE:这里
希望能帮助到你!