Forum Moderators: open
Here is a sample code :
<html>
<head>
<title>Select Box Width</title>
</head>
<body>
<h3>Drop down with onhover</h3>
<select id="id1" name="name1" style="width:60px;">
<option value="1">AAAAAAAAA</option>
<option value="2">BBBBBBBBBBBBBB</option>
<option value="3">CC</option>
<option value="4">DDDDDDDDDDDDDDDD</option>
<option value="5">EEEEE</option>
</select>
<br/>
</body>
</html>
Thanks
Sandeep
Unfortunately I don’t believe there is a way to get exactly what your want in IE. If you've got the space you maybe could do something like:
select { width: 10em; }
select:active { width: 20em; } As in resize the <select> element when it’s focussed. Of course, we’re abusing the :active pseudoclass here as IE doesn’t understand :focus, but seeing as we only want to do it for IE in the first place we can hide that code behind a conditional comment (or a CSS hack).
Just a thought though... if the SELECT box isn't wide enough to display the full text of the OPTIONs, isn't that breaking the rules of useability just a tad?
In a way yes, for that I have added a "mouseover" event on the select element - which shows the entire text that is active (a tool tip like text). There are many select elements on my webpage and in that context it is important form me to have a symmetric layout.