0

I am trying to change the width of a drop down list depending on the content by using javascript.

Example see amazon's drop down list in the first page in search section. http://www.amazon.com/ref=gno_logo

Can anyone help me?

1 Answer 1

1

Amazon uses another <span> element overlayed on top of the <select> which has its content changed to fit the select menu's value - and it uses width: auto on this tag to fit it to its contents.

So in effect, the drop-down list in Amazon is hidden while a "fake" drop-down in the form of a separate span takes its place.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.