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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS: Customizing <SELECT> box

Status
Not open for further replies.

BirdieNamNam

Programmer
Feb 12, 2004
52
SE
Dear friends!

A use a class like this
Code:
  .StdNumInput
  {
  width: 50pt;
  background-color: #fffedf;
  border-style: solid;
  border-color: #9999ff;
  }
to be used at input fields, for example a text field.
Code:
  <INPUT TYPE=&quot;text&quot; CLASS=&quot;StdNumInput&quot;>

But I also want select boxes to look the same.
Code:
  <SELECT CLASS=&quot;StdNumInput>
    <OPTION>Blah-blah</OPTION>
    ...
Can I do this, the properties in my class does not work on a select box?

Best regards, Sebastian.
 
Okey, that works for the option rows.

But my main topic here is to change the appearence of the border around the SELECT box, to make it look the same as my textboxes.

Thanks anyway, Sebastian.
 
Can't do that. Select boxes are OS dependant and as such cannot be changed. If you wish to have a special looking select box, you will need to make one out of javascript.
 
OK, thank you Vragabond!

Can you give me any nice place where I can find an easy way to program this kind of things, some tutorial, I would apriciate it!

/Sebastian.
 

>> Can't do that. Select boxes are OS dependant and as such cannot be changed

Borders can be changed around select boxes, just that some browsers choose not to render the border (IE/Win, for example). Other browsers will render the border.

You will also find that (on most browsers), the width of the select box cannot be set. It is almost always determinted by the width of the widest option.

Hope this helps,
Dan
 
paddin or W &amp; H of the &quot;box&quot; (not the form's but the CSS's)arround the form element doesnt help?
what is the &quot;select box&quot; in your mind?
sounds like ur talking about LIST/MENU no boxes here
consider this as well:
Code:
&lt;select name=&quot;select&quot;&gt;
  &lt;option selected&gt;THIS (the longest) label decies on the width....and font size will definelty change me&lt;/option&gt;
  &lt;option value=&quot;1&quot;&gt;1 this lable is shorter&lt;/option&gt;
  &lt;option value=&quot;2&quot;&gt;2 and does nothing&lt;/option&gt;
  &lt;option value=&quot;3&quot;&gt;3 to the 'width'&lt;/option&gt;
&lt;/select&gt;&lt;br&gt;
&lt;select name=&quot;select_2&quot;&gt;
  &lt;option value=&quot;dashes(characters) are valid  way of controlling the size&quot; selected&gt;----------- 
  select one -------------&lt;/option&gt;
  &lt;option value=&quot;1&quot;&gt;1&lt;/option&gt;
  &lt;option value=&quot;2&quot;&gt;2&lt;/option&gt;
  &lt;option value=&quot;3&quot;&gt;3&lt;/option&gt;
&lt;/select&gt;
HTH
All the best!

> need more info?
:: don't click HERE ::
 
Hi Lebisol!

Thanks for your answer. Really, my main concern is to make the SELECT box look as much like a text input field, with altered line types, colors and background. I've learned that there is no easy (read "HTML/CSS") way to do this, s I'll jump it for now. Thanks anyway!

/Sebastian.
 
Hi BirdieNamNam!
have u considered using JS to perhaps represent slect box with an image? or is this out of limits?
the only other thing I can think of would be playing with paddin of .class assigned to the box...but ur right for the most part u get no love with boxes.
If u dont mind using JS then something in line of "onCLick=swap image and set value to="xyz"
Good Luck!

> need more info?
:: don't click HERE ::
 
Thanks again, Lebisol! I know that I can do really anything I want with JS, and that may be the way to do it in the future. The thing is, right now, the people that shall maintain the application has no or little JavaScript knowledge. So what I was after was an easy, straightforward way to make the pages look nices. However, this is not a main problem of the application, so for now and on I can live with the standard looks of the input fields in IE. Maybe that will change in the future, but for now - I'm satisfyed. Thanks for all yor efforts.

/Sebastian.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top