Select2 change the color of the dropdown menu

Yes, so I have no idea what I'm doing. Hah

I want to change the color of select2 un-open dropdown (and maybe the button on the side), but the search for a solution only managed to lure me

.select2-choice{
  min-height: 35px;
  max-height: 35px;
  background: #222;
  overflow-y: auto;
}

.select2-search {
    background-color: #666;
}

.select2-search input {
    background-color: #666;
}
.select2-results {
    background-color: #666;
}

Which gets the options changed (which is good!), But not 100% what I need.

Is there a class that changes the color of the dropdown initial state?

+4
source share
3 answers

select2 change the color of the dropdown menu

.select2-results__option {
    background-color: red;
    color: yellow;
}

look

+1
source

this could be the answer:

I had problems with SelectBox, if you know the plugin, after 10 minutes I said to myself: "damn, this is not my problem."

, select .

, . , , , im 90% .

0

, JQuery, .

:

var changeColor = function (element, selection) {//changes colors of dropdowns
    if (selection == 1 || selection == "green") {//Mine works based on the dropdown itself
        element.css('background-color', 'green');
    }
    else if (selection == 2 || selection == "yellow") {
        element.css('background-color', 'yellow');
    }
    else {
        element.css('background-color', 'red');
    }
}

, , :

jQuery(document).ready(function ($) {
    changeColor($('#ColoredDropdown'), $('#ColoredDropdown').val());
});

, , - :

$('#FirstDropdown').change(function () {
    changeColor($('#SecondDropdown'), $('#FirstDropdown').val());
});

, ! , "" , , , , .

0

Source: https://habr.com/ru/post/1526994/


All Articles