简体   繁体   English

更改 select2 颜色

[英]Change select2 colors

How can i change the color of the following items:如何更改以下项目的颜色: 在此处输入图片说明

1.) The color of the field that appears after the page is loaded (I would apply in the classic form bg-white ) 1.) 页面加载后出现的字段颜色(我会以经典形式bg-white

2.)The color of the text that appears after the page is loaded (I would apply in the classic form text-dark ) 2.)页面加载后出现的文本颜色(我会采用经典形式text-dark

3.)Font color and element color when hovering over the mouse 3.) 鼠标悬停时的字体颜色和元素颜色

4.)Color of the field for entering text 4.) 输入文本字段的颜色

5.)The color of the first option below the text 5.)文字下方第一个选项的颜色

I found a very useful answer on the forum - source我在论坛上找到了一个非常有用的答案 - 来源

/* Input field */
.select2-selection__rendered {  }

/* Around the search field */
.select2-search {  }

/* Search field */
.select2-search input {  }

/* Each result */
.select2-results {  }

/* Higlighted (hover) result */
.select2-results__option--highlighted {  }

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

But in my situation it does not help to change the color of the elements I have placed above.但在我的情况下,改变我上面放置的元素的颜色无济于事。

Are the changes I wrote about possible, if not what are the alternative solutions?我写的更改是否可能,如果不是,有哪些替代解决方案?

I believe what you want and need is a different theme on your select2.我相信您想要和需要的是 select2 上的不同主题。 You probably have set some theme somewhere in your code, as the default theme is afaik exactly what you want您可能在代码中的某处设置了一些主题,因为默认主题正是您想要的

Please follow documentation here to change the theme:请按照此处的文档更改主题:

https://select2.org/configuration/defaults https://select2.org/configuration/defaults

This might be also interesting这可能也很有趣

https://select2.org/appearance https://select2.org/appearance

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

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