天天看點

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);

}