Controlling the drop down list width in IE8 on sel

2019-04-15 16:13发布

Is it possible to control the drop down list width on select in IE8?

When the page loads I want the drop down list to be small enough to only contain the word SELECT, but when the user clicks on it to make the selection, it should expand enough to make sure all the choices are fully visible, widthwise.

FF does it, IE9 does it. But IE8 cuts off the width.

Any fixes? thanks

2条回答
男人必须洒脱
2楼-- · 2019-04-15 16:19

Just try to include below CSS.

select:focus{width:auto !important;}

I hope it solves your problem.

查看更多
在下西门庆
3楼-- · 2019-04-15 16:39

For IE8 you will need to use some JavaScript for this. There are JQuery plugins that do this too, but I think there is no work around without using js.

Take a look at this other SO thread for different approaches and js libraries you might use.

In my experience, the best solutions involve replacing the select element with some other HTML, CSS and JavaScript combination, as trying to change the width of the original select on certain events will move the content on the right of it.

查看更多
登录 后发表回答