Connecting Tech Pros Worldwide Forums | Help | Site Map

Need help to apply style to drop down list

Hardy Wang
Guest
 
Posts: n/a
#1: Nov 19 '05
Hi all,
I have a drop down list with some items, and one of the item contains
very long text. I want to limit the width of the drop down itself, but when
I click down arrow to pull down the content, I want to make <option> item
wide enough to show all characters.

<html>
<head>
<style type="text/css">
option.wide
{
width:auto;
}
select
{
width:100px;
}
</style>
</head>
<body>
<form>
<select>
<option>This is red</option>
<option>This is blue</option>
<option>This is green</option>
<option class="wide">This is wide dhf sdlk hsdlh gldh gldek hjldr hldrh
hdrjh gh gdhg jsdghfaskjg fg f gasfkg</option>
</select>
</form>
</body>
</html>

OK, now the problem is, if I apply CSS to <select> object, the width of
<option> object will be limited too. If I remove CSS for <select>, the whole
drop down will be very wide.

Is there a solution?

Thanks!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy



Bruce Barker
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Need help to apply style to drop down list


the browser <select> does not support this. you can write your own select in
javascript using a, span, a hidden field, an image and a flyout menu. look
at any of the javascript combo box's for starting code.

-- bruce (sqlwork.com)

"Hardy Wang" <hardywang@hotmail.com> wrote in message
news:ulagDO$TFHA.2172@TK2MSFTNGP15.phx.gbl...[color=blue]
> Hi all,
> I have a drop down list with some items, and one of the item contains
> very long text. I want to limit the width of the drop down itself, but
> when I click down arrow to pull down the content, I want to make <option>
> item wide enough to show all characters.
>
> <html>
> <head>
> <style type="text/css">
> option.wide
> {
> width:auto;
> }
> select
> {
> width:100px;
> }
> </style>
> </head>
> <body>
> <form>
> <select>
> <option>This is red</option>
> <option>This is blue</option>
> <option>This is green</option>
> <option class="wide">This is wide dhf sdlk hsdlh gldh gldek hjldr hldrh
> hdrjh gh gdhg jsdghfaskjg fg f gasfkg</option>
> </select>
> </form>
> </body>
> </html>
>
> OK, now the problem is, if I apply CSS to <select> object, the width of
> <option> object will be limited too. If I remove CSS for <select>, the
> whole drop down will be very wide.
>
> Is there a solution?
>
> Thanks!
>
> --
> WWW: http://hardywang.1accesshost.com
> ICQ: 3359839
> yours Hardy
>[/color]


Closed Thread