Forum Moderators: open

Message Too Old, No Replies

Select Dropdown Option Width

IE is killing me

         

Argblat

8:44 pm on Apr 18, 2005 (gmt 0)

10+ Year Member



For the page that I am creating, I need to strictly set the width of the dropdown's...this is easy enough using css...however...the content of the down's is certain to be wider than this width. In Firefox and Netscape this is no problem because the popped-out drop down will dynamically change it's width to accomodate whatever is in the menu. However, IE is being stupid [as usual] and refuses to do the same. Is there a solution to this problem?

-Mike

Example:
<select id="Select" style="width: 125px">
<option selected>Select One</option>
<option value="1">In Firefox, this menu will expand out, despite what</option>
<option value="2">I set the width of the select itself to.</option>
<option value="3">------</option>
<option value="4">Unfortunatley, in Internet Explorer, this doesn't happen</option>
<option value="5">Is there a solution to this problem?</option>
</select>

Krapulator

6:39 am on Apr 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I guess you could do something like this:

<select id="Select" style="width: 125px;" onfocus="javascript: this.style.width='auto';" onblur="javascript: this.style.width=125;">
<option selected>Select One</option>
<option value="1">In Firefox, this menu will expand out, despite what</option>
<option value="2">I set the width of the select itself to.</option>
<option value="3">------</option>
<option value="4">Unfortunatley, in Internet Explorer, this doesn't happen</option>
<option value="5">Is there a solution to this problem?</option>
</select>

But I think it's a less than ideal situation. I don't think theres anyway around it.