在IE8和IE9中使用列表框和下拉列表裁剪数据(文本)

时间:2013-09-26 19:20:36

标签: html css drop-down-menu internet-explorer-8 internet-explorer-9

我遇到一个奇怪的问题,其中行数据输入大小大于我的下拉列表框的宽度。当发生这种情况时,文本正在缩短。

正在发生的一些例子是: -

Notice the End of text being truncated Notice the End of text being truncated This hides all the text when dropdown is clicked.

代码

守则如下: -

下拉

<div class="level select">
    <select id="MainContent_cmbClientName" style="width:140px;">

        <option selected="selected" value="Select One Two Three Four Five Six Seven Eight">Select One Two Three Four Five Six Seven Eight</option>
        <option value="Select One Two Three Four Five Six Seven Eight">Select One Two Three Four Five Six Seven Eight</option>
        <option value="Select One Two Three Four Five Six Seven Eight">Select One Two Three Four Five Six Seven Eight</option>
        <option value="Select One Two Three Four Five Six Seven Eight">Select One Two Three Four Five Six Seven Eight</option>
        <option value="Select One Two Three Four Five Six Seven Eight">Select One Two Three Four Five Six Seven Eight</option>

    </select>
</div>

选择框

<select size="4" id="MainContent_lstFamilyStatus" class="client-bg-repeat" style="color:#000060;">


    <option value="1">Couple</option>
      <option value="2">Family with 2+ Children</option>
      <option value="3">Family with One Child</option>
      <option value="4">Single Female</option>
    <option value="5">Single Female and not willing to marry</option>

</select>

我有什么方法可以解决这个问题,或者可能会将文本带到由于文本溢出而被剪切的下一行。

非常感谢。

1 个答案:

答案 0 :(得分:0)

找到下拉解决方案

<style>
.ctrDropDown{
    width:145px;
    font-size:11px;
}
.ctrDropDownClick{
    font-size:11px;

    width:300px;

}
.plainDropDown{
    width:145px;
    font-size:11px;
}
</style>


<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>

它有效(感谢Doug Boud)。

任何想法,我如何修复选择框并将溢出的文本带到下一行?

感谢。