简体   繁体   English

Select2 Library:改变选中项的背景颜色

[英]Select2 Library: change the background color of the selected item

I am working on a project and to improve the selects I have decided to use the Select2 library.我正在从事一个项目并改进我决定使用 Select2 库的选择。

The project requires a different color palette than the ones used by the library, I have spent a bit of work but I have managed to accommodate my needs with changes in the css. But I have not managed to change the blue color that highlights the selected item when displaying the select.该项目需要与图书馆使用的调色板不同的调色板,我花了一些时间,但我已经设法通过 css 中的更改来满足我的需求。但我没有设法更改突出显示所选内容的蓝色显示 select 时的项目。

It would be appreciated if someone has done something similar to guide me.如果有人做了类似的事情来指导我,我将不胜感激。 Anyway I leave an image so that you can observe what I mean:无论如何,我留下一张图片,以便您可以观察我的意思:

在此处输入图像描述

All the best...一切顺利...

Finally I find the solution... need to override the following class:最后我找到了解决方案...需要覆盖以下 class:

/* Selected option */
.select2-results__option[aria-selected=true] {  }

for example:例如:

.select2-results__option[aria-selected=true] {
    color: #ffffff;
    background-color: #9f998d;
}

Im sure I try before, but maybe I make a mistake.我确定我之前尝试过,但也许我犯了一个错误。

Hope this answer can help others... thanks StackOverflow!!!希望这个答案可以帮助其他人...感谢 StackOverflow!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM