CSS: width for <select>

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

CSS: width for <select>

Post by nigma »

Hey, when I do
select { width: 100px; }
everything works fine.

but when I do
select { width: 100%; }

the select box just dissapears. Anyone tell me why?

Thanks
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Depends on the browser. By default, select-boxes only use up as much space as the longest option-text.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

It's very difficult to style select lists and I've never seen a browser that can cope with resizing these when the page is resized.

Mac
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Not sure exactly what you're trying to do but try wrapping in a div?
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Re: CSS: width for <select>

Post by redhair »

nigma wrote:Anyone tell me why?
Using '%' for defining width (or height) is just not allowed in a select field (or any other form ellement).

I would like to see that functionality to though...
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

I just discovered a button is allowed to do 100% :)
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

Curious...a select field to :D

What browser(s) did you use when it didnt work?
I tried IE6.0 and Mozilla 1.4, both succesfully.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

redhair wrote:I tried IE6.0 and Mozilla 1.4, both succesfully.
Ooh , nice to see that someone's making forms easier to design :D .

Mac
Post Reply