天天看点

html选择框背景色,css – 如何更改选择框选项背景颜色?

您需要在选项标记上放置background-color,而不是选择标记…

select option {

margin: 40px;

background: rgba(0, 0, 0, 0.3);

color: #fff;

text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);

}

如果你想为每个选项标签样式。使用css属性选择器:

select option {

margin: 40px;

background: rgba(0, 0, 0, 0.3);

color: #fff;

text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);

}

select option[value="1"] {

background: rgba(100, 100, 100, 0.3);

}

select option[value="2"] {

background: rgba(200, 200, 200, 0.3);

}