In IE6, and possibly 7, if you set the width of an to any value other then auto, if the options inside of that select are wider then the select's width, they get cut off. this is bad. Firefox is smart enough to not do this.
Question: How can i tell if the options are being cut off with javascript?
How have you dealt with this issue other then setting width to auto?
Good question. A bit of a rant here but IE's implementation of <select> controls is abysmal. It has the following problems (among others I'm sure):
<select> cuts off <option> elements, regardless of overflow instructionsz-index) instructions. This was a huge PITA for early developers of "dialog" widgets; any dropdowns behind the dialog would bleed through overtop of the dialog itself.<option> elements<option> elements<select> does not reflect css styles set on the selected <option>
innerHTML property to a string of new option itemsvalue attribute on each <option>, mySelectBox.value silently fails <option> elements, the change event fires on every keystroke (Opera has this problem too)<option>s and <optgroup>s are generally completely ignored (only backgound-color and color work)As for your problem, one solution is to toggle the width to "auto" when the options are shown, and set if back to a set width when the options are closed, as outlined here: http://css-tricks.com/select-cuts-off-options-in-ie-fix/
The obvious drawback of this is that the screws up the flow of the document as neighboring elements all shift around to account for width:auto setting.
Take a look at this post by Chris Coyier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With