Select2 change background color

I am trying to use select2 in the webpage I am creating. However, the combobox background seems transparent, but I need to change it to a different color. I tried changing the select2.css file but nothing works. Any ideas?

+7
javascript jquery css jquery-select2
source share
2 answers

If you are trying to target shell with a list, use

 .select2-search { background-color: #00f; } 

If you are trying to target input, use

 .select2-search input { background-color: #00f; } 

And if you are trying to target the wrapping of results, use

 .select2-results { background-color: #00f; } 

Hope this helps!

+15
source share

A bit late to help the OP, but I will leave this answer in the hope that it can help someone.

I do not know about other versions, but using select2-rails 3.5.9.3 (which according to their github page means version 3.5 is used select2) I was able to change the background color only as follows:

 .select2-choice { background-color: #00f !important; } 

The selector mentioned by Matthew for the results works.

Anyway, I have not tried using "vanilla select2", so I do not know if there is a difference in this case.

+2
source share

All Articles