2

I have a dropdownlist with a lot of items that are wider than the width that I set for that control.

The desired behavior is the way Chrome handles it: the dropdownlist width specifies how much space the control takes on the page, while the dropdown itself is as wide as required to read the items in the dropdown.

I have a problem in IE (I'm using v.8 but I need compatibility with IE7 as well): the dropdown's width is always as wide as the control's width.

I've tried @BalusC's solution here: Dropdownlist width in IE but that changes the width of the control itself. The accepted answer meanwhile is outdated and has 404 links.

This question may be a duplicate of the following: DropDownList width in Internet Explorer, but the accepted answer didn't really help me (and it's over a year old).

I'm hoping some new insights are available.

So, is it possible to change the width of the dropdown on the dropdownlist control in IE without changing the width of the control itself?

Community
  • 1
  • 1
Remus
  • 1,433
  • 3
  • 14
  • 24

1 Answers1

0

Having the same problem, I spent a lot of time searching and came to the conclusion that this is not possible. The most common solution suggested on various forums and websites is to dynamically change control width according to the content width. Unfortunately, this can (and probably will) ruin the pages layout. Finally, I just created a div with a dropdown-like background image, and binded onclick event that opened an absolutely positioned div, which acted like a list. Inside it I placed paragraph tags (list items) which changes background color on :hover (list item - highlighted), and onclick events.

It works this way in all major browsers including IE6 if you use jQuery.

ZenJ
  • 313
  • 3
  • 15