Click to See Complete Forum and Search --> : Drop down list max-width ?


towser
04-14-2005, 03:21 AM
Does anyone know if it's possible to set a max-width for a select/drop down list ?

I know you can set the width to a certain number of pixels. But in this case I'm dynamically building the drop down list and I don't want to do this, as I still want to make use of the normal default width of the longest option text.

So I'm happy to use the normal default width unless it happens to be wider than say 300 pixels.

Cheers

Towser

NogDog
04-14-2005, 03:51 AM
You could try this, but I'm not sure how well it is supported by current browsers:

<select name=test style="max-width: 80px;">

BonRouge
04-14-2005, 04:03 AM
That doesn't work in crappy browsers (IE).
I was thinking you could use an expression like on this page (http://www.svendtofte.com/code/max_width_in_ie/) but I can't seem to find a good way to make it fit the select box...

towser
04-14-2005, 09:45 AM
Thanks chaps, unfortunately I discovered that bloody IE doesn't support the max-width (Thanks for nothing Bill and I know you're listening by the way !!)

It looks like this is something that just can't be done.

phpnovice
04-14-2005, 11:29 AM
So I'm happy to use the normal default width unless it happens to be wider than say 300 pixels.
Just limit the number of characters you'll load into the list. That way, you'll get the default width and your max width, too. This won't hurt a thing, in my experience, because it you set the width and your text is too long, it just gets chopped off anyway -- no horizontal scrollbar.