0

I am currently trying to properly CSS style a SELECT element.

Specifically, what I want to do is to have the initial selected value be a bit distanced from the arrow/select/icon/whatever that opens the list of options.

Currently, it appears as: VALUE[V] where [V] is the triangle/arrow button. I want to create a spacing between the end of VALUE, whatever that comes to be, and the [V] button/part of the select element. Margin is obviously not relevant and padding takes place outside of the [V] as well.

Since I have several SELECT's - is there a 'CLEAN' or 'ELEGANT' method to do this through CSS other than individually giving a width to each of these elements?

Regards G.Campos

1
  • Ugly hack... append a   to the end of the text nodes of option elements. Commented May 23, 2011 at 1:30

2 Answers 2

1

Why cant you use padding? It seems to do what you are after.. Check this out:

http://jsfiddle.net/GYyKh/1/

Sign up to request clarification or add additional context in comments.

3 Comments

Ok, so the answer is to style not SELECT but rather OPTION. I have no idea why I didn't think of that. Amateur-blues I guess. Thanks a lot for the heads up.
This doesn't work... Changing that padding amount does nothing to the space where the word in the option stops and the arrow for the dropdown begins
@Matt you are right.. it only works in firefox. Sorry Sotkra.. I will take a look again later.. when I am off the clock ;)
0

Make your select have a class so that you can call it from your css. Then do something like

.spacer {
    width:500px;
}

That will give all the elements with that class name a width that you specify

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.