DropDownList width in Internet Explorer

I have an ASP.NET DropDownList with a fairly wide content, while the width of the closed list needs to be quite small due to site space constraints. This is why I need to be able to set a specific width on the list when it is closed, but I need it to be as wide as the content when it is opened.

By default, Firefox automatically makes DropDownLists as wide as its contents when opened. On the other hand, Internet Explorer does not.

Can IE be told to open an open DDL as wide as the content when it is opened, but smaller when closed? Preferably without using javascript.

EDIT: Ok, I wasn't clear enough in my first post. The emphasis is on opening. I want a certain width in the list to close, but I want it to be as wide as the content when opened. As I said, Firefox does this, IE doesn't.

+1


a source to share


4 answers


I would recommend not to use a dropdown but a more javascript friendly one like this

http://jquery.sanchezsalvador.com/samples/example.htm



This will allow your content to expand after choosing the width.

+1


a source


IE is width up to content by default.

Install CSSClass and give it the specified width and you can change it.

You can also go



select{
  width:42px;
}

      

edit : from what you are now saying, it seems to me that you need to do some javascript because IE won't handle it. Try looking into jquery

+1


a source


IE will make it as wide as the content by default. This behavior changes if you specify the width in the DDL or constrain the DDL by placing the width somewhere in the parent container.

0


a source


I would say your best bet is to define the max width and set it in the dropdown. This way you get a consistent look regardless of the content, and you work around this problem as well.

0


a source







All Articles