When using Bootstrap 4.6, all my form select dropdowns seem to be displaying with a blue background like in this image:
https://i.sstatic.net/Vqsxw.png
In my .scss
file, I have set it up as follows:
// Custom Variables
@import '../../vendor/bootstrap-4.6.0/scss/functions';
@import '../../vendor/bootstrap-4.6.0/scss/variables';
// Bootstrap Overrides
$primary: #6b37c4;
$link-color: $primary;
$link-hover-color: darken($primary, 10%);
$WHAT-GOES-HERE-BG?: $primary; // <-- what goes here?
The issue at hand:
I am wondering if there is a specific Bootstrap 4.6 variable that can be modified to change the blue background color to something else universally.
If yes, which variable name(s) should be changed? I attempted changing variables like custom-select-bg
, custom-select-background
, form-select-bg
, but none yielded the desired results.
If not, is there an alternative method to alter this blue background for Bootstrap 4.6? I lack knowledge about browser compatibility, however, I prefer a long-lasting solution. Various suggestions on html - Change select list option background color on hover were outdated or ineffective.
An example to illustrate:
I expected the select option's background color to switch to yellow upon hovering, but it remained unchanged. Furthermore, I am unsure how to prevent the menu from closing so I could examine the CSS! It's becoming a bit frustrating.
#mySelectDiv {
max-width: 300px;
padding: 1rem;
}
option:hover {
background-color: yellow;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="43212c2c37303731223303776d756d71">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<div class="my-3" id="mySelectDiv">
<select class="custom-select" id="myCustomSelect">
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</div>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7c160d09190e053c4f5249524d">[email protected]</a>/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f0809f80809582de9a83b0c1dec1c6dec1">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ff9d90908b8c8b8d9e8fbfcbd1c9d1cd">[email protected]</a>/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>