如何更改所选选项的文字颜色?

时间:2017-11-06 21:18:15

标签: javascript css google-chrome drop-down-menu

我已将所选选项的背景颜色更改为粉红色。

enter image description here

但是,当我选择该选项时,它会将颜色设置为白色,这是我不喜欢的。

enter image description here

如何将其更改为其他内容?我尝试过设置color属性,但无济于事:

select > option:checked {
  background: linear-gradient(pink, pink);
  color: black !important; /* doesn't work */
}

Here's我的小提琴。

这可以在Chrome中使用吗?

更新:我偷看了Chrome的默认stylesheet并试了一下:

select:-internal-list-box:focus option:checked {
    color: black !important;
}

但那并没有成功。它在开发工具中显示为灰色,这意味着它没有被应用:

enter image description here

0 个答案:

没有答案