[英]Add css style to option in IE
I want to apply css style to option in select list. 我想将CSS样式应用于选择列表中的选项。
It works perfect in mozilla firefox but does not apply in IE and chrome. 它在mozilla firefox中完美运行,但不适用于IE和chrome。
<select class="mapField">
<option value="1">This is option 1 of select list</option>
<option value="2">This is option 2 of select list</option>
<option value="3">This is option 3 of select list</option>
</select>
<style>
select.mapField{
width:120px;
}
.mapField option{
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
width: 100px;
}
</style>
Thanks in advance. 提前致谢。
You can't. 你不能
<option>
is rendered by the OS, and not HTML. <option>
由操作系统而不是HTML呈现。 Except for background-color
, color
and border
, style settings applied through the style object for the option element are ignored. 除了
background-color
, color
和border
,将忽略通过style对象为option元素应用的样式设置。 You can probably search for plugins that look like <select>
, but are actually HTML elements that can be styled. 您可能可以搜索类似于
<select>
插件,但实际上是可以样式化的HTML元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.