Jump to content

select-option elements


gogi100

Recommended Posts

i have listbox in the form of

 

<select>
<option>I'm short</option>
<option>I'm medium text</option>
<option>I'm a very very very very very very very very very long text</option>

<option>I'm a very very very very very very very very very long text</option>

<option>I'm short</option>

</select>

 

how i can wrap text to long text of option elements?

i know that i can to make with css but code cannot wrap text.

some javascript maybe?

Link to comment
Share on other sites

You Should Increase The Width Of The <select> Element:

<select style="width:100%;">

That won't work. The options won't wrap, they'll just be cut off.

 

Form elements are limited in how they can be styled. To my knowledge there's no way to force an option to wrap its text.

  • Like 1
Link to comment
Share on other sites

The only way I have seen this done, is to hide the select and options elements, create clone of text values into other elements (maybe ul,li) to create dropdown, which you can now wrap, then use JavaScript to on a specific clicked list item, apply the same value as selected in hidden select option list.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...