如何为下拉列表中的每个 selectlistitem 设置样式?我可以给每个项目一个 id 并访问 in css 吗?我正在尝试更改每个项目的背景颜色...
这是代码:
@Html.DropDownListFor(model => model.BehanlingsColour, new SelectList(
new List<Object>{
new { value = 0 , text = "Red" },
new { value = 1 , text = "Blue" },
new { value = 2 , text = "Green"},
},
"value",
"text",
2))