how to add selected to css code example
Example 1: change option tag css
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-select.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap-select.min.js"></script>
<select class="selectpicker">
<option>Mustard</option>
<option class="special">Ketchup</option>
<option style="background: #5cb85c; color: #fff;">Relish</option>
</select>
Example 2: how to add a selection in css
.custom-select-wrapper {
position: relative;
user-select: none;
width: 100%;
}
.custom-select {
position: relative;
display: flex;
flex-direction: column;
border-width: 0 2px 0 2px;
border-style: solid;
border-color: #394a6d;
}
.custom-select__trigger {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 22px;
font-size: 20px;
font-weight: 300;
color: #3b3b3b;
height: 60px;
line-height: 60px;
background: #ffffff;
cursor: pointer;
border-width: 2px 0 2px 0;
border-style: solid;
border-color: #394a6d;
}
.custom-options {
position: absolute;
display: block;
top: 100%;
left: 0;
right: 0;
border: 2px solid #394a6d;
border-top: 0;
background: #fff;
transition: all 0.5s;
opacity: 0;
visibility: hidden;
pointer-events: none;
z-index: 2;
}
.custom-select.open .custom-options {
opacity: 1;
visibility: visible;
pointer-events: all;
}
.custom-option {
position: relative;
display: block;
padding: 0 22px 0 22px;
font-size: 22px;
font-weight: 300;
color: #3b3b3b;
line-height: 60px;
cursor: pointer;
transition: all 0.5s;
}
.custom-option:hover {
cursor: pointer;
background-color: #b2b2b2;
}
.custom-option.selected {
color: #ffffff;
background-color: #305c91;
}