Drop-down list in IE8 using <select> truncates option text [duplicate]

那年仲夏 提交于 2019-12-12 18:17:36

问题


Possible Duplicate:
fix size drop down with long text in options (restricted view in IE)

Drop-down lists do not work properly on IE8. Options with long text are truncated. Firefox and Chrome work fine and adjust the list window according to the longest option's text.

The following HTML is an example:

<html>
<body>
      <select STYLE="width: 150px" onchange="javascript:window.open(this.value)">
        <option value="week1.html">option 1</option>
        <option value="week2.html">many characters are here in option 2</option>
        <option value="week3.html">option 3</option>
      </select>
    </form>

  </body>

</html>

Another thread in StackOverflow suggests using css-based solution:

select:focus {
    width: auto;
    position: relative;
}

However I could not understand how to use those options in my HTML. Is this the right approach? If so, how should I use it? Any other ideas so a drop-down list in IE8 resizes dynamically like in Firefox?

Thank you.


回答1:


IE8 does not support the :focus css selector. See the following link for a coprehensive list of css supported features by browser.

http://www.quirksmode.org/css/contents.html

Your best bet is to use jQuery or another js framework which replicates the missing functionality.



来源:https://stackoverflow.com/questions/4841795/drop-down-list-in-ie8-using-select-truncates-option-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!