2017-08-07 59 views
0

所以我使用了角“GROUP BY”在我的NG选项过滤我<select>标签。所以,我想知道的是一种方法,能够将下面的风格元素添加到组头:造型组标题为NG选项中选择标签

font style: normal; 
font weight: normal; 
font-color: #b2b2b2; 

这是代码片段我想实现这一点,以供参考:

<div class="col-xs-12"> 
<select chosen ng-options="location._id as location.name group by location.company.name for location in locations" ng-model="fl.locations" multiple="true"></select> 
</div>" 

希望对此有所帮助。呵呵,我宁愿它是一个jQuery的解决方案,而是成为某种JavaScript或角指令样的解决方案的。 再次感谢:)

+0

添加代码,请 – AAT

+0

请提供[MCVE] –

+1

您需要使用基本的CSS样式的'OPTGROUP '标签。我试图做到这一点在Firefox和它的工作风格和重量,而不是颜色虽然。也看到这一点:https://stackoverflow.com/questions/7452479/how-to-change-the-style-of-a-select-box-optgroup-label –

回答

0

角呈现为每个组中的表达group byoptgroup HTML元素。

所以样式的群体,你只针对使用CSS optgroup元素:

optgroup { 
    font-weight: normal; 
    font-style: normal; 
    color: #b2b2b2; 
} 

然而,这些样式将向下级联到子option元素。所以,你需要重写任何不想要的样式需要option

optgroup { 
 
    font-weight: normal; 
 
    font-style: normal; 
 
    color: #b2b2b2; 
 
} 
 

 
option { 
 
    color: black; 
 
}
<select> 
 
    <optgroup label="Group A"> 
 
    <option>A1</option> 
 
    <option>A2</option> 
 
    </optgroup> 
 
    <optgroup label="Group B"> 
 
    <option>B1</option> 
 
    <option>B2</option> 
 
    </optgroup> 
 
</select>