Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to set the width of a drop down list?

Status
Not open for further replies.

michellerobbins56

Programmer
Jan 10, 2006
89
0
0
GB
Hi

Please can someone help me. Is there a way to set the maximum width of a drop down select list? Currently it always goes to the maximum width of the longest item in the select list. Is there anyway to reduce the "display" width of the drop down list (even though there is an item in the list that is very long)?

Thank you very much for any help.
 
Code:
<select [b]style="width: 100px;"[/b]>
This will work for you. FF will apparently crop the dropdown to be 100px and not display anything beyond that but will still make the opening big enough to fit the items. IE will just crop at 100px. I don't know what you will do after your users cannot read what the option is.
 
If you want to set the width to, say, 50 pixels, then the following will do it:
Code:
<select style="width: 50px;" size="1">
   <option value="0">First item, which is quite long.</option>
   <option value="1">Second item, which is quite long.</option>
   <option value="2">Third item, which goes on and on and on and on and on.</option>
   <option value="3">Fourth option.</option>
</select>
But, beware, there is no horizontal scroll bar, so if you had:
Code:
<select style="width: 20px;" size="1">
   <option value="0">This is an item which is first.</option>
   <option value="1">This is an item which is second.</option>
   <option value="2">This is an item which is second third.</option>
   <option value="3">This is an item which is second fourth.</option>
</select>
the user would not be able to see the text which distinguishes the four different options.

[tt]_______________________________________
Roger [pc2]
The Eileens are out there[/tt]
 
Many thanks for your help and replies. So in summary using IE there will be a problem displaying a record that is very long in the list if I have set the width to a certain size? I may have to leave setting the width if that is the case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top