Bootstrap 5 - Option Select change background color and font color

Viewed 3276

I'm trying to change the background color and the font color of the option inside the form select element. I've used Boostrap 5.

I would like when I have clicked shows the options with a custom background color and font color:

form select options enter image description here

The html code:

select option {
  background-color: yellow !important;
  color: red !important;
}
<div>
  <select class="form-select" aria-label="Default select example">
    <option selected id="Subject">Subject</option>
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
  </select>
</div>

Here the official documentation.

Maybe someone can help me.

Thanks.

1 Answers

I Don't know if I underattended you but try this..

select option:checked {
  background-color: red !important;
  color: white!important;
}

It will set a custom colors for selected item if that what u want.

Related