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!

align options in select

Status
Not open for further replies.

crazyboybert

Programmer
Jun 27, 2001
798
0
0
GB
Hi all,

sorry if this has been asked before i did a quick keyword search but dont have time for a full one and im expecting a one word answer back anyway (no) but thought id try all the same.

Anyone know of a way to centre align the options in a combo select list?

I tried css on option and select tags and attributes also with no joy.....

cheers for any thoughts

rob
 
ok i had a little further play with this and have concluded the following.

It spossible to alter the align of the options in a select list using css for NS6. by adding 'text-align:center' to the css properties of the select tag all options will align center. its a shame you cant align the individual options as this would allow staggered options which may be funky though of no real use.

However it doesnt work in IE. I suspect this is as select lists are rendered as operating system objects by IE and treated different to the other form elements. I havent tested it but it may work on the mac.

Anyone know a way to align options for IE?

rob
 
Hi crazyboybert,

Maybe you can just try and trick it a little bit. Say you put a width attribute in the select tag (using css: style="width: 300px").

Now, using css again, put an attribute style=&quot;margin-left: 120px&quot; on every <option> tag. Of course, you should adjust the value 120px until you get the correct visual effect.


This sounds a little bit tricky, but if the &quot;text-align: center&quot; does not function in Internet Explorer as you said (sorry, I can't test it right now, I'm at home and I only have Linux ;->), it's the only other solution I can think about right now...

Please, if you have time, let me know if it worked as intended.

Cheers,

xso

 
a cunning plan but alas also unsuccessful in IE. My guess remains the same. The way IE adds the select list to the page is different from other elements and is effectively an operating system element not a browser one. Hence the lack of styles available for these. I have found the following to work

font based styles (e.g. family, size, color, weight)
width
background-color

anyone know any others that work for select lists?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top