【发布时间】:2017-04-06 11:49:00
【问题描述】:
我正在使用以下 HTML 代码在我的表单中包含一个 select2 控件,如下所示。
<select id="element_id" class="select2" style="width:100%">
<option value="e1" >Element 1</option>
<option value="e2" >Element 2</option>
<option value="e3" >Element 3</option>
</select>
我正在使用以下样式来格式化列表项和选定项的字体。
<style>
#s2id_element_id .select2-container--default .select2-selection--single .select2-selection__rendered
{
color: green ;
}
</style>
这不会将列表项和选定项着色为绿色。 注意:我只需要这个特定的选择框来拥有样式而不是其他的。所以我将css id选择器用于特定的select2控件。
谢谢。
【问题讨论】:
-
这不是印刷错误,我也尝试了 element_id 和 s2id_element_id。