I'm facing a challenge with long <option>
s in my <select>
box - I don't want the box to be too wide, but when I style it smaller, the full text gets cut off. One idea is to hover a duplicate of the text exactly over the option the mouse is on, but only if the original text is too long.
The problem is that when I try to create a new element like a <p>
with jQuery, it doesn't have a width until I insert it into the document. This makes it difficult to determine whether or not to actually insert it.
Even if I manage to create the new element, I'm concerned that the styles might not match up correctly.
Is there a way to make this concept work, or is there a better solution for displaying the complete text of lengthy <option>
s without disrupting the layout?