In the picture, the width of option is larger than the select box. I want to set width of those options as same as select box & for those larger options set text-overflow as ellipsis. Any help would be appreciated.
Here is what I tried:
Html
<select>
<option>Select your University</option>
<option>Bangladesh University of Engineering and Technology</option>
<option>Mawlana Bhashani Science and Technology University</option>
</select>
Css
select, option {
width: 250px;
}
option {
overflow: hidden;
white-sapce: no-wrap;
text-overflow: ellipsis;
}
Fiddle: https://jsfiddle.net/3bsbcqfz/
I tried to find solution from css. But i failed to do it. Doesn't matter, i have write a simple javascript code for it. This is can do it something for it.
At last, I come up with the solution by creating Custom Drop-down using
ul, li.
Here is the solution:FIDDLE DEMO
HTML
CSS
JavaScript