开发者

Drop-down width -- IE labels crop

I know it is possible to set a CSS width for a drop-down menu. In FF the top window is affected by it, while the option items scale as far as the content in them, however in IE the options are also as wide开发者_运维百科 as the window, thus cutting the options' labels.

Is there a better way to control the width of SELECT element?

<select style="width:100px">
    <option>Very long label 1 is gpoing to be here</option>
    <option>Very long label 2 is gpoing to be here</option>
</select>

Drop-down width -- IE labels crop


  • When talking to developers, please refer to select elements as select elements, because a "drop-down" can infer something else entirely.

  • There is a fix here.


You could use the width: auto rule. This automatically sets the width according to the length of the options.

If that doesn't work for you, you could use Javascript to dynamically change the width of the select when it is moused over, but nothing simple will make IE8 and below act like it is supposed to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜