In our environment, we follow the standard of setting every input field to have a background color of lightgoldenyellow. I am encountering an issue with setting the background-color of the selectpicker in Bootstrap 5.
Below is the code I am using:
Additionally, here are the Bootstrap and jQuery libraries I have included:
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d4b6bbbba0a7a0a6b5a494e1fae4fae6">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" >
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"/>
<!--jQuery-->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet"/>
<!-- Bootstrap 5 Font Icon CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="01636e6e7572757360712c68626e6f7241302f30302f32">[email protected]</a>/font/bootstrap-icons.min.css">
<!--Icon Scout-->
<link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.8/css/line.css">
<!--Bootstrap/jQuery Select picker-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.14.0-beta2/css/bootstrap-select.min.css"/>
<link rel="stylesheet" href="home.css">
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9bbb6b6adaaadabb8a999ecf7e9f7eb">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.14.0-beta2/js/bootstrap-select.min.js"></script>
<div class="container" style="overflow:visible;">
<select name="instructor_a" id="" style="background-color: lightgoldenyellow;" class="selectpicker" data-live-search = "true" data-size="3" title="Select Instructor">
<?php
$query_instructor = "SELECT name_ FROM users
where userlevel = '2'";
$stmt_instructor = $pdo->prepare($query_instructor);
//$stmt_interviewee->bindParam(":training_id", $training_id);
$stmt_instructor->execute();
$result_query_instructor = $stmt_instructor->fetchAll();
foreach ($result_query_instructor as $instructors) {
echo "<option value ='$instructors[name_]'";
if($instructor_a === $instructors["name_"]) {
echo "selected";
}
echo">$instructors[name_]</option>";
}
?>
</select>
</div>
I attempted to apply an in-line style:
style="background-color:lightgoldenyellow;"
but it didn't work.
I also tried adding a class to selectpicker like class="instructor-select", and then defining the style in my CSS file using
".instructor-select {background-color:lightgoldenyellow; }"
but it still didn't work.
What would be the best way to override the default styling of the bootstrap selectpicker?